<?php
	ob_start();
	include("../header.php"); //header 
?>
<script type="text/javascript">
	function hapus2(Cat,NIK,No)
	{
		var ok = confirm("Apakah Anda yakin menghapus data tersebut ?");
		if(ok == true)
		{
			window.location.href="delete.php?cat="+ Cat +"&nik="+ NIK +"&no="+No+"";
		}
		else
		{
		}
	}
	
	function PromptSearch(){
		var Key = prompt("Masukkan Kata Kunci Anda:");
		
		if(Key){
			//alert("dsds");
			//window.location.href="search.php?show=report_emp&key="+Key"";
			top.location.href="search.php?show=report_emp&key="+ Key +" ";
		}
	}
	
	function DisableField()
	{
		
		if (document.getElementById("cek").checked == true)
		{
		document.forms[0].pendidikan.disabled = false;
		document.forms[0].fungsional.disabled = false;
		document.forms[0].skill.disabled = false;
		document.forms[0].status.disabled = false;
		}
		else
		{
		document.getElementById("pendidikan").disabled = true;
		document.getElementById("fungsional").disabled = true;
		document.forms[0].skill.disabled = true;
		document.forms[0].status.disabled = true;
		}
	}
	
	function ShowUp(NIK)
	{
		child = open
		(
			"listmedical.php?show=historical&amp;nik="+NIK+"",
			"",
			"scrollbars=no,width=500,height=400,left=150,top=150"
		);
	}
	
	function appr_per(Cat,Periode,NIK,No,Ambil,Tunda)
	{
		var ok = confirm("Apakah Anda yakin menyetujui data tersebut ?");
		if(ok == true)
		{
			window.location.href="<?=$PHP_SELF?>?periode="+ Periode +"&tahun=<?=$tahun?>&appr=yes&jenis_cuti=<?=$jenis_cuti?>&show="+ Cat +"&nik="+ NIK +"&no="+No+"&ambil="+Ambil+"&tunda="+Tunda+"";
		}
		else
		{
		}
	}

</script>
<?
include("config.php");
include("function.php");
include("header.php");
$nik	= $HTTP_GET_VARS['nik'];
$no		= $HTTP_GET_VARS['no'];
$cat	= $HTTP_GET_VARS['show'];
$show	= $HTTP_GET_VARS['show'];
$page 	= $HTTP_GET_VARS['page']; // get nomor halaman yang dipanggil
$next	= $HTTP_GET_VARS['next']; // get segmen halaman yang dipanggil
$tahun	= $HTTP_GET_VARS['tahun'];
$level	= $HTTP_GET_VARS['level'];
$keyword= $HTTP_GET_VARS['keyword'];
$divisi		= $HTTP_GET_VARS['divisi'];
$jenis_cuti = $HTTP_GET_VARS['jenis_cuti'];
$bulan1 	= $HTTP_GET_VARS['bulan1'];
$bulan2 	= $HTTP_GET_VARS['bulan2'];
$tahun1 	= $HTTP_GET_VARS['tahun1'];
$tahun2 	= $HTTP_GET_VARS['tahun2'];
$status 	= $HTTP_GET_VARS['status'];

if($cat == "employee"){
	
	/////////////////////////////////////
	/// Untuk Pencarian Berdasarkan Kategori Unit Kerja/Status Kerja
	/////////////////////////////////////
		
	echo"
	<table>
	 <tr height=10>
	  <td></td>
	 </tr>
	</table>
	";
	
	SearchMK($cat,$conn,$st,$divisi,$sb);

	// pesan delete berhasil
	if($_GET['delete'] == "yes" && !empty($_GET['nik'])){
		$s1 = "delete from Karyawan where NIK='".$_GET['nik']."'";
		$s2 = "delete from Bahasa where NIK='".$_GET['nik']."'";
		$s3 = "delete from Cuti where NIK='".$_GET['nik']."'";
		$s4 = "delete from CutiTahunan where NIK='".$_GET['nik']."'";
		$s5 = "delete from Karir where NIK='".$_GET['nik']."'";
		$s6 = "delete from KaryawanFoto where NIK='".$_GET['nik']."'";
		$s7 = "delete from KaryawanStatus where NIK='".$_GET['nik']."'";
		$s8 = "delete from Keluarga where NIK='".$_GET['nik']."'";
		$s9 = "delete from Kenalan where NIK='".$_GET['nik']."'";
		$s10 = "delete from Kursus where NIK='".$_GET['nik']."'";
		$s11 = "delete from LP2 where NIK='".$_GET['nik']."'";
		$s12 = "delete from LP2Detail where NIK='".$_GET['nik']."'";
		$s13 = "delete from MedicalRestitusi where NIK='".$_GET['nik']."'";
		$s14 = "delete from MedicalRestitusiDetail where NIK='".$_GET['nik']."'";
		$s15 = "delete from MedicalSetupAwal where NIK='".$_GET['nik']."'";
		$s16 = "delete from MonitoringKontrak where NIK='".$_GET['nik']."'";
		$s17 = "delete from MK_TrackRecords where NIK='".$_GET['nik']."'";
		$s18 = "delete from MK_Certification where NIK='".$_GET['nik']."'";
		$s19 = "delete from Organisasi where NIK='".$_GET['nik']."'";
		$s20 = "delete from Pendidikan where NIK='".$_GET['nik']."'";
		$s21 = "delete from PengalamanLN where NIK='".$_GET['nik']."'";
		$s22 = "delete from PengalamanRef where NIK='".$_GET['nik']."'";
		$s23 = "delete from Penugasan where NIK='".$_GET['nik']."'";
		$s24 = "delete from Pribadi where NIK='".$_GET['nik']."'";
		$s25 = "delete from Sanksi where NIK='".$_GET['nik']."'";
		$s26 = "delete from Pendidikan where NIK='".$_GET['nik']."'";
		$s27 = "delete from TrainingKaryawan where NIK='".$_GET['nik']."'";
		
		$res_delete	= mssql_query($s1,$conn);
		$res_delete	= mssql_query($s2,$conn);
		$res_delete	= mssql_query($s3,$conn);
		$res_delete	= mssql_query($s4,$conn);
		$res_delete	= mssql_query($s5,$conn);
		$res_delete	= mssql_query($s6,$conn);
		$res_delete	= mssql_query($s7,$conn);
		$res_delete	= mssql_query($s8,$conn);
		$res_delete	= mssql_query($s9,$conn);
		$res_delete	= mssql_query($s10,$conn);
		$res_delete	= mssql_query($s11,$conn);
		$res_delete	= mssql_query($s12,$conn);
		$res_delete	= mssql_query($s13,$conn);
		$res_delete	= mssql_query($s14,$conn);
		$res_delete	= mssql_query($s15,$conn);
		$res_delete	= mssql_query($s16,$conn);
		$res_delete	= mssql_query($s17,$conn);
		$res_delete	= mssql_query($s18,$conn);
		$res_delete	= mssql_query($s19,$conn);
		$res_delete	= mssql_query($s20,$conn);
		$res_delete	= mssql_query($s21,$conn);
		$res_delete	= mssql_query($s22,$conn);
		$res_delete	= mssql_query($s23,$conn);
		$res_delete	= mssql_query($s24,$conn);
		$res_delete	= mssql_query($s25,$conn);
		$res_delete	= mssql_query($s26,$conn);
		$res_delete	= mssql_query($s27,$conn);
		
		?>
        <div align="center" style="padding:3px 3px 3px 3px; color:#0000FF;">Data Pegawai Sudah Dihapus</div>
        <?
	}
		
	$sqlmk  = "SELECT count(*) FROM VLatestKarir A, MstSO B WHERE A.kode_so2=B.kode_so AND B.AreaCode IN (";
	for($k=0;$k<count($VAreaCode);$k++){
		$sqlmk .= "'$VAreaCode[$k]',";
	}
	$sqlmk .= "'$VAreaCode[0]') ";
	$sqlmk .= "AND Jenis NOT IN ('U','H') ";

	$result	= mssql_query($sqlmk,$conn);
	$total	= mssql_fetch_row($result);
	$limit	= 20;
	$pager  = Pager::getPagerData($total[0], $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	$sqlnmk  = "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, NIK, Nama, Alamat FROM VLatestKarir A, MstSO B WHERE A.kode_so2=B.kode_so AND B.AreaCode IN (";
	for($k=0;$k<count($VAreaCode);$k++){
		$sqlnmk .= "'$VAreaCode[$k]',";
	}
	$sqlnmk .= "'$VAreaCode[0]') ";
	$sqlnmk .= " AND Jenis NOT IN ('U','H') ) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit)."";
	
	$sql	= mssql_query($sqlnmk,$conn); 
	echo"<br><br>";
	Paging($pager,$page,$next,$limit,$keyword,$show,$conn,$st,$divisi,$sb);
	echo"<table cellpadding=2 width=100%>";
	HeadKaryawanFront();
	while($row = mssql_fetch_array($sql)){
		echo"
		<tr class='contentlist'>
		 <td><a href='detailemp.php?show=data_umum&amp;nik=$row[NIK]'>$row[No]</a></td>
		 <td><a href='detailemp.php?show=data_umum&amp;nik=$row[NIK]'>$row[NIK]</a></td>
		 <td><a href='detailemp.php?show=data_umum&amp;nik=$row[NIK]'>$row[Nama]</a></td>
		 <td><a href='detailemp.php?show=data_umum&amp;nik=$row[NIK]'>$row[Alamat]</a></td>
		 ";
		 
		$sqlx	= mssql_query("SELECT * FROM KarirPTSI WHERE NIK='$row[NIK]' ORDER BY seqno DESC",$conn);
		$rowx 	= mssql_fetch_array($sqlx);
				
		if(empty($rowx[kode_so1])){
			$kodeso = $rowx[kode_so2];
		}
		else{
			$kodeso = $rowx[kode_so1];
		}
		
		if(empty($kodeso)){
			echo"<td>&nbsp;</td>";
			echo"<td>&nbsp;</td>";
		}
		else{
			$s1 = mssql_query("SELECT * FROM VLevelCabang WHERE substring(kode_so,1,7)='".substr($kodeso,0,7)."'", $conn);
			if(mssql_num_rows($s1) > 0){
				$r1 = mssql_fetch_array($s1);
				if(!empty($r1[uraian])){
					echo"<td><a href='detailemp.php?show=data_umum&amp;nik=$row[NIK]'>$r1[uraian]</a></td>";
				}
				else{
					echo"<td>&nbsp;</td>";
					echo"<td>&nbsp;</td>";
					echo"<td>&nbsp;</td>";
				}			
				$s3 = mssql_query("SELECT * FROM MstLokasi WHERE kode_lokasi='".$r1[kode_lokasi]."'",$conn);
				$r3 = mssql_fetch_array($s3);
				if(!empty($r3[distrik])){
					echo"<td><a href='detailemp.php?show=data_umum&amp;nik=$row[NIK]'>$r3[distrik]</a></td>";
				}
				else{
					echo"<td>&nbsp;</td>";
				}
			}
			else{
					echo"<td>&nbsp;</td>";
					echo"<td>&nbsp;</td>";
			}
		}	
		
		// get status karyawan
		if(empty($rowx[stat_kar1])){
			$status = $rowx[stat_kar2];
		}
		else{
			$status = $rowx[stat_kar1];
		}
		
		// jika yang dipilih berhenti
		if($rowx[Jenis] == "U" || $rowx[Jenis] == "H"){
			echo"<td>Berhenti</td>";
		}
		else{
			$s4 = mssql_query("SELECT * FROM VStatusKaryawan WHERE kode='".$status."'",$conn);
			$r4 = mssql_fetch_array($s4);
			if(!empty($r4[Nama])){
				echo"<td><a href='detailemp.php?show=data_umum&amp;nik=$row[NIK]'>$r4[Nama]</a></td>";
			}
			else{
				if($row[pelamar] == "1"){
					echo"<td><a href='detailemp.php?show=data_umum&amp;nik=$row[NIK]'>Pelamar</a></td>";
				}
				else{
					echo"<td>&nbsp;</td>";
				}
			}
		}
		echo"
		 <td width=1%><a href='#' onclick='Javascript:del_emp(\"".$row[NIK]."\");'><img src='../images/b_delete.png' border='0' alt='Hapus Pegawai' title='Hapus Pegawai'></a></td>
		</tr>
		";
	}
	//ShowData($conn,$sql,$cat);
	echo"</table>";
}

elseif($cat == "report_emp"){
	$log_id = $HTTP_GET_VARS['log_id'];

	if(empty($log_id)){
		header("Location: ../form/frm_log_cvonline.php");
	}

	echo"
	<table width=93% class='table_indent'>
	 <tr>
	  <td colspan=2 class=line_bottom><b>&nbsp;&nbsp;&nbsp;CV ONLINE</b></td>
	 </tr>
	</table>
	";
	/////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\
	/// Untuk Pencarian Berdasarkan Kategori Unit Kerja/Status Kerja
	/////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\
	SearchFilter($cat,$conn,$log_id);
	
	/*
	$result	= mssql_query("SELECT count(*) FROM SearchCVOnline ",$conn);
	$total	= mssql_fetch_row($result);
	$limit	= 20;
	$pager  = Pager::getPagerData($total[0], $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	$sql	= "with limit as (select row_number() over (order by nik) as no, NIK, nama, tempatlahir, CONVERT(CHAR(12), tgl_lahir, 103) TglLahir, alamat, notelepon, uraian from searchcvonline) select * from limit where no between ".$offset." AND ".($offset+$limit).""; 
	*/
	//PagingFilter($pager,$page,$next,$limit,$keyword,$show,$unit_kerja,$status_kerja);
	//PagingFilter($pager,$page,$next,$limit,$keyword,$show,$pendidikan,$fungsional,$skill);
	//echo"<table cellpadding=2>";
	//HeadKaryawan();
	//ShowData2($conn,$sql,$cat);
	//echo"</table>";
}
// untuk karir di ptsi
elseif($cat == "karirptsi"){
	echo"
		<table width=100% height=200>
		 <tr>
		  <td colspan=2 align=left valign=top><br>
		  <form method='get' action=search.php>
		  <fieldset><legend>Pencarian Karir Pegawai Selama di PT Surveyor Indonesia</legend>
		   <table border=0>
		    <tr>
			 <td width=145 align=left valign=top>&nbsp;&nbsp;Masukkan NIK/Nama:</td>
			 <td>
			 <input type='hidden' name='show' value='karirptsi'>
			 <input type='text' name='keyword'>";
	echo"
		<select name='divisi'>
		 <option value='all'>---semua divisi---</option>";
		$sq2 = mssql_query("SELECT * FROM VLevelCabang WHERE status='1' ORDER BY uraian ASC",$conn);
			while($rq2 = mssql_fetch_array($sq2)){
				echo"<option value='".$rq2[kode_so]."'";
				if($divisi == $rq2[kode_so]){
					echo" selected";
				}
			echo">$rq2[uraian]</option>";
		}
	echo"	 
		</select>
		</td>
		</tr>
		<tr>
		 <td>&nbsp;&nbsp;Status Karyawan:</td>
		 <td><select name='stat_kar'>
	    <option value='all'>--semua--</option>";
	$sq = mssql_query("SELECT * FROM VStatusKaryawan",$conn);
	while($rq = mssql_fetch_array($sq)){
		echo"<option value='".$rq[kode]."'";
		if($stat_kar == $rq[kode]){
			echo" selected";
		}
		echo">$rq[Nama]</option>";
	}
	echo"
        </select> &nbsp;&nbsp;Status Karyawan <select name=\"st\">
   <option value=\"all\">--semua--</option>
   <option value=\"bekerja\""; 
   if($st=="bekerja"){ echo" selected"; } echo">Bekerja</option>";
   echo"<option value=\"berhenti\""; 
   if($st=="berhenti"){ echo" selected"; } echo">Berhenti</option>
   </select></td>
		</tr>
		<tr>
		 <td></td>
		 <td>
	";
	echo"		 
			 <input type=submit value='Cari' class=button>";
		// untuk hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='karir_ptsi'",$conn);
	$rpar = mssql_fetch_array($spar);			  
		// tambah
		if($rpar[tambah] == 1){
		echo"<input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_karir_ptsi.php\"'></td>";
		}
			 echo"</td>
			</tr>
		   </table>
		   </form>
		  </td>
		 </tr>
		</table>
	";
}
// untuk track record
elseif($cat == "track_record"){
	// hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='track_record'",$conn);
	$rpar = mssql_fetch_array($spar);	

	echo"
		<table width=93% class='table_indent2'>
		 <tr>
		  <td colspan=2 class=line_bottom>&nbsp;&nbsp;<b>PENCARIAN TRACK RECORD</b></td>
		 </tr>
		 <tr>
		  <td colspan=2 align=center>
		  <form method='get' action=search.php>
		   <table>
		    <tr>
			 <td width=200 align=right>Masukkan NIK/Nama:</td>
			 <td>
			 <input type='hidden' name='show' value='track_record'>
			 <input type='text' name='keyword'><input type=submit value='Cari' class=button></td>
			</tr>
		   </table>
		   </form>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		   <table width=100%>
		    <tr class=headlist>
			 <td>No.</td>
			 <td>Track Start</td>
			 <td>Track End</td>
			 <td>Product</td>
			 <td>Project</td>
			 <td>Job Description</td>
			</tr>
			<tr height=100>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			</tr>
		   </table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		  <br><br><br>";
		  // tambah
		  if($rpar[tambah] == 1){
		  echo"<input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_emp_track_record.php\"'>";
		  }
		  echo"
		  </td>
		 </tr>
		</table>
	";
}
// untuk DETAIL TRACK RECORD
elseif($cat == "detail_track_record"){
	$nik	= $HTTP_GET_VARS['nik'];
	$no		= $HTTP_GET_VARS['no'];
	$query	= mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, *, CONVERT(CHAR(12), Track_start, 103) TrackStart, CONVERT(CHAR(12), Track_end, 103) TrackEnd FROM VTrackRecord WHERE NIK='$nik') SELECT * FROM limit WHERE No='$no'",$conn);
	$row	= mssql_fetch_array($query);
	// hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='track_record'",$conn);
	$rpar = mssql_fetch_array($spar);	

echo'	
	<table width=93% class=\'table_indent2\' cellpadding="">
	 <tr>
	  <td colspan="2">
		<table width="100%" style="border:none;">
		<tr>
		 <td colspan="2" style="border-bottom:solid 1px #666666; font-size:12px; font-weight:bold;">TRACK RECORD</td>
		</tr>
		<tr>
		</table>
	  </td>
	 </tr>
	 <tr>
	  <td>&nbsp;</td>
	 </tr>
	 <tr>
	  <td width="150"><b>NIK</b></td>
	  <td>'.$row[NIK].'</td>
	 </tr>
	 <tr>
	  <td width="150"><b>Nama</b></td>
	  <td>'.$row[Nama].'</td>
	 </tr>
	 <tr>
	  <td>Track Start</td>
	  <td>'.$row[TrackStart].'</td>
	 </tr>
	 <tr>
	  <td>Track End</td>
	  <td>'.$row[TrackEnd].'</td>
	 <tr>
	  <td valign="top">Client</td>
	  <td valign="top">'.$row[Client].'</td>
	 <tr>
	  <td valign="top">Product</td>
	  <td valign="top">'.$row[Product].'</td>
	 </tr>
	 <tr>
	  <td valign="top">Project</td>
	  <td valign="top">'.$row[Project].'</td>
	 </tr>
	  <td valign="top">Job Description</td>
	  <td valign="top">'.$row[Job_Desc].'</td>
	 </tr>
	 <tr>
	  <td>&nbsp;</td>
	  <td><br><br />
	  <form action="update.php" method="post">
	  <input type="button" value="Cancel" onclick="Javascript:history.back()" class="button" />';
	  
	  // edit
	  if($rpar[edit] == 1){
	  echo'
	  <input type="button" value="Edit" class="button" onclick="Javascript:location.href=\'../form/frm_emp_track_record.php?nik='.$row[NIK].'&amp;no='.$row[No].'&amp;op=edit\'" />';
	  }
	  echo'
	  <input type="hidden" name="nik" value="'.$row[NIK].'">
	  <input type="hidden" name="approval" value="yes">
  	  <input type="hidden" name="cat" value="track_record">
  	  <input type="hidden" name="no" value="'.$row[No].'">	  ';
	  // approval
	  if($rpar[approval] == 1){
	  echo'
	  <input type="submit" value="Approval" id="setuju" class="button" />';
	  }
	  echo'
	  </form>
	  </td>
	 </tr>
	</table>
	</form>';
	
}
// untuk SANKSI
elseif($cat == "sanksi"){
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='sanksi'",$conn);
	$rpar = mssql_fetch_array($spar);	
	echo"<table>
	<tr>
	<td></td>
	</tr>
	</table>";
		 SearchSanksi($conn,$st,$filter,$show,$keyword,$b1,$b2,$t1,$t2); 
	echo"
		<table width=100% height=100>
		 <tr>
		  <td colspan=2 align=center>&nbsp;";
	echo" </td>
		 </tr>
		 <tr>
		  <td colspan=2>";
		  //tambah
		  if($rpar[tambah] == 1){
		  echo"<input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_emp_sanksi.php\"'>";
		  }
		  echo"
		  </td>
		 </tr>
		</table>
	";
}
// untuk DETAIL SANKSI
elseif($cat == "detail_sanksi"){
	$nik	= $HTTP_GET_VARS['nik'];
	$no		= $HTTP_GET_VARS['no'];
	$query	= mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM VSanksi WHERE NIK='$nik') SELECT * FROM limit WHERE No='$no'",$conn);
	$row	= mssql_fetch_array($query);
	// hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='sanksi'",$conn);
	$rpar = mssql_fetch_array($spar);	

echo'	
<table width=93% class=\'table_indent2\'>
 <tr>
  <td colspan="2">
   <table>
    <tr>
	 <td>NIK:</td>
	 <td><b>'.$row[NIK].'</b></td>
	</tr>
    <tr>
	 <td>Nama:</td>
	 <td><b>'.$row[Nama].'</b></td>
	</tr>	
   </table>
  </td>
 </tr>
 <tr>
  <td colspan="2"><hr noshade="noshade" size="-2"/></td>
 </tr>
  <td valign="top" colspan="2">
  <fieldset><legend>SURAT KEPUTUSAN - SANKSI KARYAWAN</legend>
  <table width=100%>
 <tr>
  <td width="100"><b>No. Surat:</b></td>
  <td><b>'.$row[no_surat].'</b></td>
 </tr>
 <tr>
  <td>Tanggal Berlaku:</td>
  <td>'.$row[TglBerlaku].'</td>
 </tr>
 <tr>
  <td>Tanggal Keluar:</td>
  <td>'.$row[TglKeluar].'</td>
 </tr>
 <tR> 
  <td>Kategori Sanksi:</td>
  <td>';
  // get kat sanksi
  $gks = mssql_query("SELECT nama FROM VKatSanksi WHERE kode='".$row[category]."'",$conn);
  $rks = mssql_fetch_array($gks);
  echo"$rks[nama]";
  echo'</td>
 </tr>
 <tr>
  <td colspan="2"><br>
  Sanksi:<br />
  <textarea cols="45" rows="7" readonly>'.$row[sanksi].'</textarea>
  </td>
 </tr>
 <tr>
  <td colspan="2">
  Keterangan:<br />
  <textarea cols="45" rows="7" readonly>'.$row[keterangan].'</textarea>
  </td>
 </tr>
 </table>
 </fieldset>
 </td>
 </tr>
</table>
<table width=100%>
 <tr>
  <td colspan=2 align=center><br>
  <input type="button" class=button value="Cancel" onclick="Javascript:history.back();">';
  // edit
  if($rpar[edit] == 1){
  echo'
  <input type="button" class=button value=Tambah onclick=Javascript:location.href="../form/frm_emp_sanksi.php?nik='.$row[NIK].'">';
  }

  // delete
  if($rpar[hapus] == 1){
  echo'
  <input type="button" class=button value=Edit onclick=Javascript:location.href="../form/frm_emp_sanksi.php?op=edit&amp;no='.$row[No].'&amp;nik='.$row[NIK].'">';
  }
  echo'
  <br><br>
  </td>  
 </tr>
</table>

	';	
}
// untuk PENUGASAN
elseif($cat == "penugasan"){
	// hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='penugasan'",$conn);
	$rpar = mssql_fetch_array($spar);	

	echo"
		<table width=93% class='table_indent2'>
		 <tr>
		  <td colspan=2 class=line_bottom>&nbsp;&nbsp;<b>PENCARIAN PENUGASAN</b></td>
		 </tr>
		 <tr>
		  <td colspan=2 align=center>
		  <form method='get' action=search.php>
		   <table>
		    <tr>
			 <td width=200 align=right>Masukkan NIK/Nama:</td>
			 <td>
			 <input type='hidden' name='show' value='penugasan'>
			 <input type='text' name='keyword'><input type=submit value='Cari' class=button></td>
			</tr>
		   </table>
		   </form>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		   <table width=100%>
		    <tr class=headlist>
			 <td>No.</td>
			 <td>No. Surat</td>
			 <td>Tanggal Surat</td>
			 <td>Dari</td>
			 <td>Sampai</td>
			 <td>Tujuan</td>
			 <td>Keterangan</td>
			 <td>Lokasi</td>
			 <td>Unit Kerja</td>
			</tr>
			<tr height=100>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>	
			 <td class=contentlist>&nbsp;</td>	
			</tr>
		   </table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		  <br><br><br>";
		// tambah
		if($rpar[tambah] == 1){
		  echo"
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_emp_penugasan.php\"'>
		  ";
		}
		  echo"
		  </td>
		 </tr>
		</table>
	";
}
elseif($cat == "detail_tugas"){

	$stugas 	= mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM VPenugasan WHERE NIK='$nik' ) SELECT * FROM limit WHERE No='$no'",$conn);
	$rtugas		= mssql_fetch_array($stugas);
	// hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='penugasan'",$conn);
	$rpar = mssql_fetch_array($spar);		
?>
<form name="FEmployee" method="post" action=" <?=$Faction?> ">
   <table width=93% class='table_indent2'>
    <tr>
	 <td class="line_bottom">&nbsp;&nbsp;<b>Penugasan</b></td>
	</tr>
   </table>
<table width="91%" border="0" style="position:relative; left:80px;">
 <tr>
  <td colspan="2">&nbsp;</td>
 </tr>
 <tr>
  <td colspan="2">
   <table width="100%">
    <tr>
	 <td width="100">NIK</td>
	 <td><?=$rtugas[NIK]?></td>
	</tr>
	<tr>
	 <td>Nama</td>
	 <td><?=$rtugas[Nama]?></td>
	</tr>
	<tr>
	 <td colspan="2"><hr noshade="noshade" size="-2" /></td>
	</tr>
   </table>
  </td>
 </tr>
 <tr>
 <td valign="top" width="50%" colspan="2">
 <fieldset><legend>SURAT KEPUTUSAN</legend>
 <table width="100%" border="0">
 <tr>
  <td width="150"><b>No. Surat</b></td>
  <td><b>: <?=$rtugas[no_surat]?></b></td>
 </tr>
 <tr>
  <td>Tanggal Surat</td>
  <td>: <?=$rtugas[TglSurat]?>
  </td>
 </tr>
 <tr>
  <td>Dari Tanggal</td>
  <td>: <?=$rtugas[TglDari]?></td>
 </tr>
 <tr>
  <td>Sampai Tanggal</td>
  <td>: <?=$rtugas[TglSampai]?></td>
 </tr>
 <tr>
  <td valign="top" colspan="2">Tujuan: </td>
 </tr>
 <tr>
  <td valign="top" colspan="2"><textarea name="tujuan" rows="6" cols="60" readonly="readonly"><?=$rtugas[tujuan]?></textarea></td>
 </tr>
 <tr>
  <td valign="top" colspan="2">Keperluan: </td>
 </tr>
 <tr>
  <td valign="top" colspan="2"><textarea name="tujuan" rows="6" cols="60" readonly="readonly"><?=$rtugas[keperluan]?></textarea></td>
 </tr>
 </table>
 </fieldset>
 </td>
 <!--
 <td valign="top">
 <fieldset><legend>DATA KARYAWAN</legend>
 <table> 
 <tr>
  <td width="110">Lokasi:</td>
  <td> 
  	<?
	/*
		$sLok	= mssql_query("SELECT * FROM MstLokasi WHERE kode_lokasi='$rtugas[lokasi]'",$conn);
		$rLok	= mssql_fetch_array($sLok);
		echo"$rLok[distrik] - $rLok[propinsi] ";
	*/
	?>
  </td>
 </tr>
 <tr>
  <td>Unit Kerja:</td>
  <td> 
  	<?
	/*
		$sSO	= mssql_query("SELECT * FROM MstSO WHERE kode_so='$rtugas[kode_so]'",$conn);
		$rSO	= mssql_fetch_array($sSO);
		echo"$rSO[uraian]";
	*/
	?>
  </td>
 </tr>
 <tr>
  <td valign="top">Detail Posisi:</td>
  <td valign="top"><?=$rtugas[DetailPosisi]?></td>
 </tr>

 <tr>
  <td>Jabatan:</td>
  <td><?=$rtugas[jabatan]?></td>
 </tr>

 <tr>
  <td>Nama Jabatan:</td>
  <td><?=$rtugas[nama_jab]?></td>
 </tr>
 <tr>
  <td>Golongan:</td>
  <td><?=$rtugas[golongan]?></td>
 </tr>
 <tr>
  <td>Status Karyawan:</td>
  <td>
  <?
  /*
  	$stat	= mssql_query("SELECT * FROM VStatusKaryawan WHERE kode='$rtugas[stat_kar]'",$conn);
	$rtat	= mssql_fetch_array($stat);
	echo"$rtat[Nama]";
	*/
  ?>
  </td>
 </tr>
 </table>
 </fieldset>
 </td>
 -->
 </tr>
 <tr>
  <td align="right" colspan="2">
  <?
  	//tambah
	if($rpar[tambah] == 1){
  ?>
   <input type="button" value="Tambah" class="button" onclick="Javascript:location.href='../form/frm_emp_penugasan.php?nik=<?=$rtugas[NIK]?>&amp;nama=<?=$rtugas[Nama]?>'" />
   <?
   }
   //edit
   if($rpar[edit] == 1){
   ?>
   <input type="button" value="Edit" class="button" onclick="Javascript:location.href='../form/frm_emp_penugasan.php?nik=<?=$rtugas[NIK]?>&amp;no=<?=$rtugas[No]?>&amp;op=edit'"/>
   <?
   }
   ?>
  </td>
 </tr>
</table>
<?
}
// untuk penilaian
elseif($cat == "penilaian"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2 class=line_bottom>&nbsp;&nbsp;<b>PENCARIAN PENILAIAN KARYAWAN</b></td>
		 </tr>
		 <tr>
		  <td colspan=2 align=center>
		  <form method='get' action=search.php>
		   <table>
		    <tr>
			 <td width=200 align=right>Masukkan NIK/Nama:</td>
			 <td>
			 <input type='hidden' name='show' value='penilaian'>
			 <input type='text' name='keyword'><input type=submit value='Cari' class=button></td>
			</tr>
		   </table>
		   </form>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		   <table width=100%>
		    <tr class=headlist>
			 <td>No.</td>
			 <td>NIK</td>
			 <td>Tahun</td>
			 <td>Unsur Penilaian</td>
			 <td>Penilaian 1</td>
			 <td>Penilaian 2</td>
			 <td>Penilaian 3</td>			 
			 <td>Catatan</td>			 
			</tr>
			<tr height=100>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>
			 <td class=contentlist>&nbsp;</td>			 
			</tr>
		   </table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		  <br><br><br>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_emp_fpenilaian.php\"'>
		  </td>
		 </tr>
		</table>
	";
}

/// DETAIL PENILAIAN
elseif($cat == "detail_nilai"){
	$sqlN 	= mssql_query("SELECT * FROM karyawan WHERE NIK='$nik' ",$conn);
	$rqlN	= mssql_fetch_array($sqlN);
	// get tahun
	$sqlT = mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM VPenilaian WHERE NIK='$nik' AND tahun='$tahun') SELECT * FROM limit",$conn);
	$rowT = mssql_fetch_array($sqlT);
	echo"
	<table width=93% class='table_indent2'>
	 <tr>
	  <td colspan=2 class='line_bottom'>&nbsp;&nbsp;<b>DETAIL PENILAIAN KARYAWAN</b></td>
	 </tr>
	 <tr>
	  <td width=100	>&nbsp;&nbsp;NIK:</td>
	  <td>$rqlN[NIK]</td>
	 </tr>
	 <tr>
	  <td>&nbsp;&nbsp;Nama:</td>
	  <td>$rqlN[Nama]</td>
	 </tr>	
	 <tr>
	  <td>&nbsp;&nbsp;Tahun:</td>
	  <td>$rowT[tahun]</td>
	 </tr>
	 <tr>
	  <td colspan=2 align=right><input type='button' value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_emp_penilaian.php?nik=$rqlN[NIK]&amp;nama=$rqlN[Nama]&amp;tahun=$tahun\"'></td>
	 </tr>
	 <tr>
	  <td colspan=2>
	  <table style='position:relative; left: 5px;' width=100%>
	    <tr class=headlist>
		 <td>No.</td>
		 <td>Unsur Penilaian</td>
		 <td>Penilaian I</td>
		 <td>Penilaian II</td>
		 <td>Penilaian III</td>	
 		 <td>Jumlah</td>	
		 <td>Catatan</td>
  	 	 <td colspan=2>&nbsp;</td>
		</tr>";
		$sqlL = mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM VPenilaian WHERE NIK='$nik' AND tahun='$tahun') SELECT * FROM limit",$conn);
		while($rowL = mssql_fetch_array($sqlL)){
			echo"
			<tr>
			 <td>$rowL[No]</td>
			 <td>$rowL[UnsurName]</td>
			 <td>$rowL[nilai1]</td>
			 <td>$rowL[nilai2]</td>
			 <td>$rowL[nilai3]</td>";
			 $jumlah = ($rowL[nilai1] + $rowL[nilai2] + $rowL[nilai3]);
			 echo"
			 <td>$jumlah</td>
			 <td>$rowL[catatan]</td>
	 		 <td><a href='../form/frm_emp_penilaian.php?nik=$nik&amp;no=$rowL[No]&amp;op=edit'><img src='../images/b_edit.png' border=0></a></td>
			 <td><a href='#' onclick='hapus2(\"penilaian\",\"$nik\",\"$rowL[No]\")'><img src='../images/b_delete.png' border=0></a></td>
			</tr>
			";
		}
	   echo"</table>
	  </td>
	 </tr> 
	 <tr>
	  <td colspan=2 class='line_bottom'>&nbsp;</td>
	 </tr>
	 <tr>
	  <td colspan=2>&nbsp;&nbsp;<b>DAFTAR PENILAI:</b></td>
	 </tr>
	 <tr>
	  <td colspan=2>";
	  // daftar nama penilai
		 $SSL 	= mssql_query("SELECT * FROM LP2 WHERE NIK='$nik' AND tahun='$tahun'",$conn);
		 $rSSL 	= mssql_fetch_array($SSL);
		 // untuk jumlah penilai
		 if($rSSL[penilai1] == ""){
		 	$P1 = 0;
		 }
		 else{
		 	$P1 = 1;
		 }
		 
		 if($rSSL[penilai2] == ""){
		 	$P2 = 0;
		 }
		 else{
		 	$P2 = 1;
		 }

		 if($rSSL[penilai3] == ""){
		 	$P3 = 0;
		 }
		 else{
		 	$P3 = 1;
		 }

		 $jum_penilai = $P1+$P2+$P3;
		 
	  // jumlah nilai
		 $sNilai= mssql_query("WITH AJE AS (select nik, tahun, sum(nilai1) N1, sum(nilai2) N2, sum(nilai3) N3 from VPenilaian GROUP BY NIK,tahun ) SELECT (N1+N2+N3) jumlah FROM AJE WHERE NIK='$nik' AND tahun='$tahun'",$conn);
		 $rNilai= mssql_fetch_array($sNilai);
	  // jumlah unsur
	  	 $sUnsur= mssql_query("select count(unsur) jumlah from lp2detail WHERE NIK='$nik' AND tahun='$tahun'",$conn);
		 $rUnsur= mssql_fetch_array($sUnsur);
		 
echo"	  
	   <table style='position: relative; left: 15px;'>
	    <tr>
		 <td>Penilai I</td>
		 <td>: $rSSL[penilai1]</td>
		 <td width=100>&nbsp;</td>
		 <td>Total Nilai</td>
		 <td>: $rNilai[jumlah]</td>
		</tr>
	    <tr>
		 <td>Penilai II</td>
		 <td>: $rSSL[penilai2]</td>
		 <td>&nbsp;</td>	
		 <td>Jumlah Penilai</td>
		 <td>: $jum_penilai</td>
		</tr>
	    <tr>
		 <td>Penilai III</td>
		 <td>: $rSSL[penilai3]</td>
		 <td>&nbsp;</td>
		 <td>Jumlah Unsur</td>
		 <td>: $rUnsur[jumlah]</td>
		</tr>
		<tr>
		 <td>&nbsp;</td>
		 <td>&nbsp;</td>
		 <td>&nbsp;</td>
		 <td>Rata-rata</td>
		 <td>: ".round(($rNilai[jumlah]/$rUnsur[jumlah]),2)."</td>		 		 		 		 
		</tr>
		<tr>
		 <td>&nbsp;</td>
		 <td>&nbsp;</td>
		 <td>&nbsp;</td>
		 <td>Hasil Penilaian</td>
		 <td>: &nbsp;</td>		 		 		 		 
		</tr>
	   </table>
	  </td>
	 </tr>
	</table>
	";
}

// CUTI KARYAWAN
elseif($cat == "cuti"){

	$sparC = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='cuti'",$conn);
	$rparC = mssql_fetch_array($sparC);	
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2 class=line_bottom>&nbsp;&nbsp;<b>PENCARIAN CUTI KARYAWAN</b></td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>";
	SearchCuti($conn,$bulan1,$bulan2,$tahun1,$tahun2,$divisi);	
	echo"</td>
		 </tr>
		 <tr>
		  <td colspan=2>";
		// untuk persetujuan cuti tahunan  
		if($HTTP_GET_VARS['appr'] == "yes" && $HTTP_GET_VARS['ambil'] == "0"){
			$sql = mssql_query("WITH limit AS (SELECT * FROM CutiTahunan WHERE NIK='".$nik."' AND id='".$no."') UPDATE limit SET aktif='A', ambil='0', tunda='0' WHERE id='".$no."'",$conn);
		}
		
		if($HTTP_GET_VARS['appr'] == "yes" && $HTTP_GET_VARS['tunda'] == "1"){
			$sql = mssql_query("WITH limit AS (SELECT * FROM CutiTahunan WHERE NIK='".$nik."' AND id='".$no."') UPDATE limit SET aktif='A', ambil='0', tunda='1' WHERE id='".$no."'",$conn);
		}
		
		if($HTTP_GET_VARS['appr'] == "yes" && $HTTP_GET_VARS['ambil'] == 1){
			$sql = mssql_query("WITH limit AS (SELECT * FROM CutiTahunan WHERE NIK='".$nik."' AND id='".$no."') UPDATE limit SET aktif='A', ambil='1' WHERE id='".$no."'",$conn);
		}
	  // get pengajuan cuti tahunan
	  $sqlxy = "SELECT * FROM CutiTahunan A, VLatestKarir B, MstSO C WHERE B.kode_so2=C.kode_so AND A.NIK=B.NIK AND (aktif='P' OR aktif='T') AND C.AreaCode IN (";
		
		for($k=0;$k<count($VAreaCode);$k++){
			$sqlxy .= "'$VAreaCode[$k]',";
		}
		
		$sqlxy 	.= "'$VAreaCode[0]')";	

	  $sqlxy .= " ORDER BY tgl_cuti DESC";
	  $sqlcutix = mssql_query($sqlxy,$conn);
		
	//$result	= mssql_query("SELECT count(*) FROM Karyawan",$conn);
	$total	= mssql_num_rows($sqlcutix);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	PagingMedCut($pager,$page,$next,$limit,$keyword,$show,$conn,$status,$divisi,$bulan1,$bulan2,$tahun1,$tahun2,$jenis_cuti);
		
		echo"
		<fieldset>
		 <legend><b>Daftar Pengajuan CUTI TAHUNAN</b></legend>
		 <table width='100%'>
		  <tr class=headlist>
		   <td>No</td>
		   <td>Tanggal Cuti</td>
		   <td>NIK</td>
		   <td>Nama</td>
		   <td>Divisi/Biro/Unit Kerja</td>
		   <td>Periode</td>
		   <td>Sisa Cuti</td>
		   <td width=150>Status</td>
		   <td>&nbsp;</td>
		  </tr>";
		  
	  // get pengajuan cuti tahunan
	  $sqlxd = "WITH ASDF AS (SELECT ROW_NUMBER() OVER(ORDER BY tgl_cuti DESC) No, CONVERT(CHAR(12), tgl_cuti, 103) Tgl, A.*,B.Nama,B.kode_so2 FROM CutiTahunan A, VLatestKarir B, MstSO C WHERE A.NIK=B.NIK AND B.kode_so2=C.kode_so AND C.AreaCode IN (";
	  
		for($k=0;$k<count($VAreaCode);$k++){
			$sqlxd .= "'$VAreaCode[$k]',";
		}
		
		$sqlxd 	.= "'$VAreaCode[0]')";	
	  
	  $sqlxd .= " AND (aktif='P' OR aktif='T')) SELECT * FROM ASDF WHERE No BETWEEN $offset AND ".($offset+$limit)." ORDER BY tgl_cuti DESC";
	  $sqlcuti = mssql_query($sqlxd,$conn);
		  while($rowcuti = mssql_fetch_array($sqlcuti)){
		  	echo"
			<tr class=contentlist>
			 <td align=right>$rowcuti[No]</td>
			 <td>$rowcuti[Tgl]</td>
			 <td>$rowcuti[NIK]</td>
			 <td>$rowcuti[Nama]</td>";
			 
			$kodeso = $rowcuti[kode_so2];
			
			if(empty($kodeso)){
			}
			else{
				$s1 = mssql_query("SELECT * FROM VLevelCabang WHERE substring(kode_so,1,7)='".substr($kodeso,0,7)."'", $conn);
				if(mssql_num_rows($s1) > 0){
					$r1 = mssql_fetch_array($s1);
					if(!empty($r1[uraian])){
						echo"<td style='font-size:8px;'>$r1[uraian]</td>";
					}
					else{
						echo"<td>&nbsp;</td>";
					}			
				}
				else{
						echo"<td>&nbsp;</td>";
				}
			}	
		
			echo"
			 <td style='font-size:9px;'>$rowcuti[periode]</td>
			 <td align=center>";
			////////////////// get sisa cuti  
            // get jatah cuti tahunan
            $gj = mssql_query("SELECT jatah_cuti, syarat_waktu FROM VJCuti WHERE nama='Cuti Tahunan'",$conn);
            $rj = mssql_fetch_array($gj);
            $jatah_cuti = $rj[jatah_cuti];
            $syarat_cuti= $rj[syarat_waktu];
			// sisa cuti
			$sqlsisa 	= mssql_query("SELECT count(*) jumlah FROM CutiTahunan WHERE NIK='$rowcuti[NIK]' AND periode='$rowcuti[periode]' AND aktif IN ('A',NULL) AND (ambil='1' OR tunda='0')",$conn);
			$cntsisa 	= mssql_fetch_array($sqlsisa);
			$sisa_cuti	= $jatah_cuti - $cntsisa[jumlah];
			
			echo"$sisa_cuti</td>
			 <td>";
			 if($rowcuti[aktif] == "A"){
			 	echo"Disetujui";
			 }
			 elseif($rowcuti[aktif] == "T"){
			 	echo"<span style='color: red; font-size:9px;'>(<b>Pengajuan Cuti Tunda $rowcuti[keterangan]</b>)</span>";
			 }
			 else{
			 	if($rowcuti[tunda] == 1){
				 	echo"<span style='color: red; font-size:9px;'>(<b>Pengajuan Tunda Cuti</b>)</span>";
				}
				else{
				 	echo"<span style='color: red; font-size:9px;'>(<b>Pengajuan Cuti</b>)</span>";
				}
			 }
			echo"</td>
			<td><a href='../report/rep_cuti.php?nik=$rowcuti[NIK]&amp;cuti=tahunan&amp;no=$rowcuti[id]&amp;periode=".$pert."' target='_blank'><img src='../images/fileprint.png' title='Cetak Surat Permohonan' alt='Cetak Surat Permohonan' border=0></a>";
			// approval
			if($rparC[approval] == 1){
			echo"
			<a href='#' Onclick='Javascript:appr_per(\"cuti\",\"".$pert."\",\"$rowcuti[NIK]\",\"$rowcuti[id]\",\"$rowcuti[ambil]\",\"$rowcuti[tunda]\");'><img src='../images/apply.png' title='Approval/\Persetujuan' alt='Approval/\Persetujuan' border=0></a>";
			}
			// edit
			if($rparC[edit] == 1){
			echo"
			<a href='../form/frm_emp_cuti.php?show=cuti_tahunan_ed&amp;op=edit&amp;nik=$rowcuti[NIK]&amp;no=$rowcuti[id]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a>";
			}
			//hapus
			if($rparC[hapus] == 1){
			echo"
			<a href='#' Onclick='Javascript:hapus2(\"cuti_tahunan\",\"$rowcuti[NIK]\",\"$rowcuti[id]\");'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'>";
			}
			echo"</td>
			</tr>
			";
		  }
		  echo"
		 </table>
		</fieldset>
		";
		echo"</td>
		 </tr>
		</table>
	";
	mssql_free_result($sqlcuti);
}
// MEDICAL KARYAWAN
elseif($cat == "medical"){
	echo"
		<table width=93% class='table_indent2' border='0'>
		 <tr>
		  <td colspan=2 class=line_bottom>&nbsp;&nbsp;<b>DAFTAR MEDICAL KARYAWAN</b> | <a href='$PHP_SELF?show=setup_medical'>DAFTAR PLAFON MEDICAL</a></td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>";
			  $bulan1 = $HTTP_GET_VARS['bulan1'];
			  $bulan2 = $HTTP_GET_VARS['bulan2'];
			  $tahun1 = $HTTP_GET_VARS['tahun1'];
			  $tahun2 = $HTTP_GET_VARS['tahun2'];
			  $divisi = $HTTP_GET_VARS['divisi'];
		echo"<fieldset><legend>Berdasarkan Periode:</legend>";	  
		   SearchMedical($conn,$bulan1,$bulan2,$tahun1,$tahun2,$divisi,$jenis);
		   echo"
		  </td>
		 </tr>
		 <tr>
		  <td>";
		
	//$sql	= "SELECT ROW_NUMBER() OVER (ORDER BY TGL DESC) AS No, CONVERT(CHAR(12), TGL, 103) Tanggal, NMR nomor, * FROM VListUpMedical WHERE status='P'";
/*	
	$sqlmedc = "WITH DDD AS (SELECT ROW_NUMBER() OVER (ORDER BY TGL DESC) AS No, CONVERT(CHAR(12), TGL, 103) Tanggal, NMR nomor, A.* FROM VListUpMedical A, VLatestKarir B, MedicalRestitusiDetail C, MstSO D WHERE A.NMR=C.nomor AND B.NIK=C.NIK AND B.kode_so2=D.kode_so AND A.status='P' AND D.AreaCode IN (";
	
	for($k=0;$k<count($VAreaCode);$k++){
		$sqlmedc .= "'$VAreaCode[$k]',";
	}
	
	$sqlmedc 	.= "'$VAreaCode[0]')";	

	$sqlmedc .= ") SELECT * FROM DDD WHERE No BETWEEN $offset AND ".($offset+$limit)."";
*/	
	$sql	= "SELECT ROW_NUMBER() OVER (ORDER BY TGL DESC) AS No, CONVERT(CHAR(12), TGL, 103) Tanggal, NMR nomor, A.* FROM VListUpMedical A, VLatestKarir B, MedicalRestitusiDetail C, MstSO D WHERE A.NMR=C.nomor AND B.NIK=C.NIK AND B.kode_so2=D.kode_so AND A.status='P' AND D.AreaCode IN (";
	for($k=0;$k<count($VAreaCode);$k++){
		$sql .= "'$VAreaCode[$k]',";
	}
	
	$sql 	.= "'$VAreaCode[0]')";	

	$result	= mssql_query($sql,$conn);
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;	
	// get data medical terbaru
	//PagingMedCut($pager,$page,$next,$limit,$keyword,$show,$conn,$status,$divisi,$bulan1,$bulan2,$tahun1,$tahun2,$jenis_cuti);
	PagingMedSaja($pager,$page,$next,$limit,$keyword,$show,$conn,$status,$divisi,$jenis,$awal,$akhir,$jenis_cuti);
	//$sqlmedc = "WITH DDD AS (SELECT ROW_NUMBER() OVER (ORDER BY TGL DESC) AS No, CONVERT(CHAR(12), TGL, 103) Tanggal, NMR nomor, * FROM VListUpMedical WHERE status='P') SELECT * FROM DDD WHERE No BETWEEN $offset AND ".($offset+$limit)."";

	$sqlmedc = "WITH DDD AS (SELECT ROW_NUMBER() OVER (ORDER BY TGL DESC) AS No, CONVERT(CHAR(12), TGL, 103) Tanggal, NMR nomor, A.* FROM VListUpMedical A, VLatestKarir B, MedicalRestitusiDetail C, MstSO D WHERE A.NMR=C.nomor AND B.NIK=C.NIK AND B.kode_so2=D.kode_so AND A.status='P' AND D.AreaCode IN (";
	
	for($k=0;$k<count($VAreaCode);$k++){
		$sqlmedc .= "'$VAreaCode[$k]',";
	}
	
	$sqlmedc 	.= "'$VAreaCode[0]')";	

	$sqlmedc .= ") SELECT * FROM DDD WHERE No BETWEEN $offset AND ".($offset+$limit)."";

	$sqlmed = mssql_query($sqlmedc,$conn);
		  echo"</td>
		 </tr>
		 <tr>
		  <td>
		  <fieldset>
		  <legend>Daftar Pengajuan</legend>
		  <table width=100%>";
		  echo"
		   <tr class=headlist>
		    <!--<td width=25 align='right'>No.</td>-->
			<td width=75>Tanggal</td>
			<!--<td width=100>No. Restitusi</td>-->
			<td width=100>NIK</td>
			<td>Nama</td>
			<td>Divisi/Biro/Unit Kerja</td>
			<td>Jenis</td>
			<td>Status</td>
			<td>&nbsp;</td>
		   </tr>";
		  while($rowmed = mssql_fetch_array($sqlmed)){
		  	echo"
			<tR class=contentlist>
			 <!--<td align='right'>$rowmed[No]</td>-->
			 <td>$rowmed[Tanggal]</td>
			 <!--<td width=120>$rowmed[nomor]</td>-->";
			 // get nik dan divisi
			 $slate = mssql_query("SELECT * FROM VLatestKarir A, MedicalRestitusiDetail B WHERE A.NIK=B.NIK AND B.nomor='$rowmed[nomor]'",$conn);
			 $rlate = mssql_fetch_array($slate);
			 echo"
			  <td><a href='../form/frm_emp_medical.php?nikg=$rlate[NIK]&amp;no_res=$rowmed[nomor]&amp;st=setuju'>$rlate[NIK]</a></td>
			  <td><a href='../form/frm_emp_medical.php?nikg=$rlate[NIK]&amp;no_res=$rowmed[nomor]&amp;st=setuju'>$rlate[Nama]</td>
			 ";
		//if(empty($rlate[kode_so1])){
			$kodeso = $rlate[kode_so2];
		//}
		//else{
			//$kodeso = $rlate[kode_so1];
		//}
		
		if(empty($kodeso)){
			//echo"<td>&nbsp;</td>";
			//echo"<td>&nbsp;</td>";
		}
		else{
			$s1 = mssql_query("SELECT * FROM VLevelCabang WHERE substring(kode_so,1,7)='".substr($kodeso,0,7)."'", $conn);
			if(mssql_num_rows($s1) > 0){
				$r1 = mssql_fetch_array($s1);
				if(!empty($r1[uraian])){
					echo"<td style='width: 250px;'><a href='../form/frm_emp_medical.php?nikg=$rlate[NIK]&amp;no_res=$rowmed[nomor]&amp;st=setuju'>$r1[uraian]</td>";
				}
				else{
					echo"<td style='width: 250px;'>&nbsp;</td>";
				}			
			}
			else{
					echo"<td style='width: 250px;'>&nbsp;</td>";
			}
		}	
		
			// jenis
			echo"<td style='color: blue;'><small>";
			switch($rlate[mata_anggaran]){
				case "811101":
					echo"Rawat Jalan";
					break;
				case "811103":
					echo"Rawat Jalan";
					break;
				case "811199":
					echo"Rawat Jalan";
					break;
				case "811102":
					echo"Rawat Inap";
					break;
				case "811104":
					echo"Kaca Mata";
					break;
				case "811106":
					echo"Persalinan";
					break;
			}
			echo"</td>";

			echo" 
			 <td>";
			if($rlate[status] == "A"){
				echo"<a href='../form/frm_emp_medical.php?nikg=$rlate[NIK]&amp;no_res=$rowmed[nomor]&amp;st=setuju'>Disetujui";
			}
			else{
				echo"<a href='../form/frm_emp_medical.php?nikg=$rlate[NIK]&amp;no_res=$rowmed[nomor]&amp;st=setuju'><span style='color:red;'>Sedang diproses</span>";
			}
			echo"</td>
			<td><a href='listmedical.php?show=historical&amp;nik=$rlate[NIK]' target='_blank'><img src='../images/detail.png' border='0' title='Detil Medical Pegawai' alt='Detil Medical Pegawai'></a></td>
			</tR>
			";
		  }
		  echo"
		  </table>
		  </fieldset>
		  </td>
		 </tr>
		</table>
	";
}
// SETUP MEDICAL KARYAWAN
elseif($cat == "setup_medical"){
		  $bulan1 = $HTTP_GET_VARS['bulan1'];
		  $bulan2 = $HTTP_GET_VARS['bulan2'];
		  $tahun1 = $HTTP_GET_VARS['tahun1'];
		  $tahun2 = $HTTP_GET_VARS['tahun2'];
		  $divisi = $HTTP_GET_VARS['divisi'];
	 // untuk hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='setup_medical'",$conn);
	$rpar = mssql_fetch_array($spar);	

	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2 class=line_bottom>&nbsp;&nbsp;<a href='$PHP_SELF?show=medical'>DAFTAR MEDICAL KARYAWAN</a> | <a href='$PHP_SELF?show=setup_medical'><b>DAFTAR PLAFON MEDICAL</b></a></td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>";
	SearchPlafonMedical($conn,$bulan1,$bulan2,$tahun1,$tahun2,$divisi);
	echo"
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>";
		  if($rpar[tambah] == 1){
		  echo"<input type=button value=\"Tambah\" class=\"button\" onclick=Javascript:location.href=\"../form/frm_emp_plafon.php?show=plafon_awal\">";
		  }
		  echo"
		  </td>
		 </tr>";
		//$sqlx = "SELECT A.NIK,A.Nama FROM VSetupMedical A, VLatestKarir B WHERE A.NIK=B.NIK AND (A.NIK LIKE '%$keyword%' OR B.Nama LIKE '%$keyword%') GROUP BY A.NIK,A.Nama";
		$sqlx = "SELECT A.NIK,A.Nama FROM VSetupMedical A, VLatestKarir B, MstSO C WHERE B.kode_so2=C.kode_so AND A.NIK=B.NIK AND (A.NIK LIKE '%$keyword%' OR B.Nama LIKE '%$keyword%') AND C.AreaCode IN (";

		for($k=0;$k<count($VAreaCode);$k++){
			$sqlx .= "'$VAreaCode[$k]',";
		}
		
		$sqlx 	.= "'$VAreaCode[0]')";		
		$sqlx .= " GROUP BY A.NIK,A.Nama";

		$sql_num 	= mssql_query($sqlx,$conn);
		
		$total	= mssql_num_rows($sql_num);
		$limit	= 15;
		$pager  = Pager::getPagerData($total, $limit, $page);
		$offset = $pager->offset;
		$limit  = $pager->limit;
		$page   = $pager->page;

		echo"
		<tr>
		 <td colspan=3>";
		Paging3($pager,$page,$next,$limit,$keyword,$show,$divisi,$tahun1);
		echo"</td>
		</tr>
		";
		if($total > 0){
		 echo"<tr>
		  <td colspan=2>
		   <table width=100%>
		    <tr class=headlist>
			 <td width=1%>No</td>
			 <td width=80>NIK</td>
			 <td>Nama</td>
			 <td>Divisi/Biro/Unit Kerja</td>
			</tr>";

			$sqlxxx = "WITH AJX AS (SELECT ROW_NUMBER() OVER (ORDER BY A.NIK) AS No, A.NIK, A.Nama FROM VLatestKarir A, VSetupMedical B, MstSO C WHERE A.kode_so2=C.kode_so AND (A.NIK LIKE '%$keyword%' OR A.Nama LIKE '%$keyword%') AND A.NIK=B.NIK AND C.AreaCode IN (";
			
			for($k=0;$k<count($VAreaCode);$k++){
				$sqlxxx .= "'$VAreaCode[$k]',";
			}
			
			$sqlxxx 	.= "'$VAreaCode[0]')";	
			
			if(!empty($divisi)){
				$sqlxxx .= " AND (substring(kode_so1,1,7)='".substr($divisi,0,7)."' OR substring(kode_so2,1,7)='".substr($divisi,0,7)."') ";
			}
			
			if(!empty($tahun1)){
				$sqlxxx .= " AND Periode ='".$tahun1."' ";
			}
			
			$sqlxxx .= "  GROUP BY A.NIK,A.Nama ) SELECT * FROM AJX WHERE No BETWEEN $offset AND ".($offset+$limit)."";
			
			$sql = mssql_query($sqlxxx,$conn);
			if(mssql_num_rows($sql) > 0){
			while($row = mssql_fetch_array($sql)){
			  echo"<tr class=contentlist>
				 <td class=contentlist align='right'><a href='listmedical.php?show=setup_medical&amp;nik=$row[NIK]'>$row[No]</a></td>
				 <td class=contentlist><a href='listmedical.php?show=setup_medical&amp;nik=$row[NIK]'>$row[NIK]</a></td>
				 <td class=contentlist><a href='listmedical.php?show=setup_medical&amp;nik=$row[NIK]'>$row[Nama]</a></td>";
			 // get nik dan divisi
			 $slate = mssql_query("SELECT * FROM VLatestKarir A, VSetupMedical B WHERE A.NIK=B.NIK AND A.NIK='$row[NIK]'",$conn);
			 $rlate = mssql_fetch_array($slate);
				 
			if(empty($rlate[kode_so1])){
				$kodeso = $rlate[kode_so2];
			}
			else{
				$kodeso = $rlate[kode_so1];
			}
			
			if(empty($kodeso)){
				//echo"<td>&nbsp;</td>";
				//echo"<td>&nbsp;</td>";
			}
			else{
				$s1 = mssql_query("SELECT * FROM VLevelCabang WHERE substring(kode_so,1,7)='".substr($kodeso,0,7)."'", $conn);
				if(mssql_num_rows($s1) > 0){
					$r1 = mssql_fetch_array($s1);
					if(!empty($r1[uraian])){
						echo"<td><a href='listmedical.php?show=setup_medical&amp;nik=$row[NIK]'>$r1[uraian]</td>";
					}
					else{
					}			
				}
				else{
				}
			}				 
				 
			  echo"</tr>";
			}
			}
			else{
			echo"
			<tr>
			 <td colspan=10 align=center style='color:red; text-indent:50px;'><b>Maaf, Pencarian tidak ditemukan ...</b></td>
			</tr>
			";
			}
		}
		else{
			echo"
			<tr>
			 <td colspan=10 align=center style='color:red; text-indent:50px;'><b>Maaf, Pencarian tidak ditemukan ...</b></td>
			</tr>
			";
			//exit();
		}
	   echo'</table>
		  </td>
		 </tr>
		</table>
	';
}
// PARAMETER SETUP (LP2)
elseif($cat == "par_lp2"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		 ";
	if($level == "par_lp2_cari")	 
	{
		$result	= mssql_query("SELECT * FROM MstUnsurLP2 WHERE (UnsurID LIKE '%$keyword%') OR (UnsurName LIKE '%$keyword%') ",$conn);
		//$result	= mssql_query("SELECT count(*) FROM MstLokasi WHERE distrik LIKE '%$keyword%' ",$conn);
	}
	else{
		$result	= mssql_query("SELECT * FROM MstUnsurLP2",$conn);
	}
	
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	if($level == "par_lp2_cari")
	{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY UnsurID) AS No, * FROM MstUnsurLP2 WHERE (UnsurID LIKE '%$keyword%') OR (UnsurName LIKE '%$keyword%')) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
		//$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_lokasi) AS No, * FROM MstLokasi WHERE (distrik LIKE '%$keyword%')) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	else{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY UnsurID) AS No, * FROM MstUnsurLP2) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo"</td>
		 </tr>
		 <tr>
		  <td>
		   <div >
		   <form method=get action=show.php?show=par_lokasi&amp;level=par_lokasi_cari>
		   Masukkan Kode Penilaian/Nama Unsur: <input type='text' name='keyword' >
		   <input type='hidden' name='show' value='par_lp2'>
		   <input type='hidden' name='level' value='par_lp2_cari'>
		   <input type='submit' value='Cari!' class=button>
		   </form>
		   </div>
		  </td>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_lp2.php\"'>&nbsp;
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td>Kode</td>
			  <td>Nama Unsur Penilaian</td>
			  <td width=1% colspan=2>&nbsp;</td>		  			  
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td>$rLokasi[UnsurID]</td>
			  <td>$rLokasi[UnsurName]</td>
			  <td><a href='../form/frm_par_lp2.php?op=edit&amp;KL=$rLokasi[UnsurID]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"par_lp2\",\"$rLokasi[UnsurID]\",\"\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>		 
			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_lp2.php\"'>&nbsp;
		  </td>
		 </tr>
		</table>
	";
}
// VIEW PENAMBAHAN KATEGORY UNSUR PENILAIAN
elseif($cat == "cat_lp2"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		 ";
	if($level == "cat_lp2_cari")	 
	{
		$result	= mssql_query("SELECT * FROM S_LP_Cat_Nilai WHERE (category LIKE '%$keyword%') ",$conn);
		//$result	= mssql_query("SELECT count(*) FROM MstLokasi WHERE distrik LIKE '%$keyword%' ",$conn);
	}
	else{
		$result	= mssql_query("SELECT * FROM S_LP_Cat_Nilai",$conn);
	}
	
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	if($level == "cat_lp2_cari")
	{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY category) AS No, category FROM S_LP_Cat_Nilai WHERE (category LIKE '%$keyword%') group by category) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
		//$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_lokasi) AS No, * FROM MstLokasi WHERE (distrik LIKE '%$keyword%')) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	else{
		//$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY category) AS No, category FROM s_lp_cat_nilai GROUP BY category) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY category) AS No, category FROM S_LP_Cat_Nilai group by category) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo"</td>
		 </tr>
		 <tr>
		  <td>
		   <div>
		   <form method=get action=show.php?show=par_lokasi&amp;level=par_lokasi_cari>
		   Masukkan Nama Kategori: <input type='text' name='keyword' >
		   <input type='hidden' name='show' value='cat_lp2'>
		   <input type='hidden' name='level' value='cat_lp2_cari'>
		   <input type='submit' value='Cari!' class=button>
		   </form>
		   </div>
		  </td>
		  <td align=right>
		  <!--
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_cat_lp2.php\"'>&nbsp;
		  -->
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td>Nama Kategori</td>
			  <td>Unsur Penilaian</td>
			  <td width=1% colspan=2>&nbsp;</td>		  			  
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td>$rLokasi[category]</td>
			  <td>";
			  echo"
			   <table>
			  ";
			  $sUP = mssql_query("SELECT ROW_NUMBER() OVER(ORDER BY UnsurID) No, * FROM s_lp_cat_nilai A, MstUnsurLP2 B WHERE A.unsur_penilai=B.UnsurID AND category='$rLokasi[category]'");
			  while($rUP = mssql_fetch_array($sUP)){
			  	echo"
				 <tr>
				  <td align=right>$rUP[No].</td>
				  <td>$rUP[UnsurName]</td>
				 </tr>
				";
			  }
			  echo"</table>";
			echo"</td>
			  <td><a href='../form/frm_cat_lp2.php?op=edit&amp;category=$rLokasi[category]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"par_cat_lp2\",\"$rLokasi[category]\",\"\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>		 
			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=right>
		  <!--
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_cat_lp2.php\"'>&nbsp;
		  -->
		  </td>
		 </tr>
		</table>
	";
}
// PARAMETER SETUP (FUNGSIONAL)
elseif($cat == "par_fungsional"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		 ";
	if($level == "par_fungsional_cari")	 
	{
		$result	= mssql_query("SELECT * FROM MstFungsional WHERE (kode LIKE '%$keyword%') OR (nama LIKE '%$keyword%') ",$conn);
	}
	else{
		$result	= mssql_query("SELECT * FROM MstFungsional",$conn);
	}
	
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	if($level == "par_fungsional_cari")
	{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode) AS No, * FROM MstFungsional WHERE (kode LIKE '%$keyword%') OR (nama LIKE '%$keyword%')) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	else{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode) AS No, * FROM MstFungsional) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo"</td>
		 </tr>
		 <tr>
		  <td>
		   <div>
		   <form method=get action=show.php?show=par_lokasi&amp;level=par_lokasi_cari>
		   Masukkan Kode Fungsional/Nama Fungsional: <input type='text' name='keyword' >
		   <input type='hidden' name='show' value='par_fungsional'>
		   <input type='hidden' name='level' value='par_fungsional_cari'>
		   <input type='submit' value='Cari!' class=button>
		   </form>
		   </div>
		  </td>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_fungsional.php\"'>&nbsp;
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td>Kode Fungsional</td>
			  <td>Nama Fungsional</td>
			  <td width=1% colspan=2>&nbsp;</td>		  			  
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td>$rLokasi[kode]</td>
			  <td>$rLokasi[nama]</td>
			  <td><a href='../form/frm_par_fungsional.php?op=edit&amp;KL=$rLokasi[kode]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"par_fungsional\",\"$rLokasi[kode]\",\"\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>		 
			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_fungsional.php\"'>&nbsp;
		  </td>
		 </tr>
		</table>
	";
}
// PARAMETER SETUP (LOKASI)
elseif($cat == "par_lokasi"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		 ";
	if($level == "par_lokasi_cari")	 
	{
		$result	= mssql_query("SELECT * FROM MstLokasi WHERE (distrik LIKE '%$keyword%') OR (propinsi LIKE '%$keyword%') ",$conn);
	}
	else{
		$result	= mssql_query("SELECT * FROM MstLokasi",$conn);
	}
	
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	if($level == "par_lokasi_cari")
	{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY distrik) AS No, * FROM MstLokasi WHERE (distrik LIKE '%$keyword%') OR (propinsi LIKE '%$keyword%')) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	else{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY distrik) AS No, * FROM MstLokasi) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo"</td>
		 </tr>
		 <tr>
		  <td>
		   <div>
		   <form method=get action=show.php?show=par_lokasi&amp;level=par_lokasi_cari>
		   Masukkan Nama Kota/Propinsi: <input type='text' name='keyword' >
		   <input type='hidden' name='show' value='par_lokasi'>
		   <input type='hidden' name='level' value='par_lokasi_cari'>
		   <input type='submit' value='Cari!' class=button>
		   </form>
		   </div>
		  </td>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_lokasi.php\"'>&nbsp;
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td>Kota</td>
			  <td>Propinsi</td>
			  <td width=1% colspan=2>&nbsp;</td>		  			  
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td>$rLokasi[distrik]</td>
			  <td>$rLokasi[propinsi]</td>
			  <td><a href='../form/frm_par_lokasi.php?op=edit&amp;KL=$rLokasi[kode_lokasi]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"par_lokasi\",\"$rLokasi[kode_lokasi]\",\"\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>		 
			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_lokasi.php\"'>&nbsp;
		  </td>
		 </tr>
		</table>
	";
}

// PARAMETER SETUP (JENIS CUTI)
elseif($cat == "par_jns_cuti"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		 ";
	if($level == "par_jns_cuti_cari")	 
	{
		$result	= mssql_query("SELECT * FROM MstJenisCuti WHERE (uraian LIKE '%$keyword%')",$conn);
	}
	else{
		$result	= mssql_query("SELECT * FROM MstJenisCuti",$conn);
	}
	
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	if($level == "par_jns_cuti_cari")
	{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY id_jcuti) AS No, * FROM MstJenisCuti WHERE (uraian LIKE '%$keyword%')) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	else{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY id_jcuti) AS No, * FROM MstJenisCuti) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo"</td>
		 </tr>
		 <tr>
		  <td>
		   <div>
		   <form method=get action=show.php?show=par_lokasi&amp;level=par_lokasi_cari>
		   Masukkan Nama Jenis Cuti: <input type='text' name='keyword' >
		   <input type='hidden' name='show' value='par_jns_cuti'>
		   <input type='hidden' name='level' value='par_jns_cuti_cari'>
		   <input type='submit' value='Cari!' class=button>
		   </form>
		   </div>
		  </td>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_jenis_cuti.php\"'>&nbsp;
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td>Nama Cuti</td>
			  <td>Jatah Cuti</td>
			  <td>Syarat Waktu</td>
			  <td>Akumulasi</td>
			  <td>Otorisasi</td>
			  <td>Istimewa</td>
			  <td>Syarat Sex</td>
			  <td width=1% colspan=2>&nbsp;</td>		  			  
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td>$rLokasi[uraian]</td>
			  <td align=right>$rLokasi[jatah_cuti]</td>
			  <td align=right>$rLokasi[syarat_waktu]</td>
			  <td align=right>$rLokasi[akumulasi]</td>
			  <td align=right>$rLokasi[otorisasi]</td>
			  <td align=right>$rLokasi[istimewa]</td>
			  <td align=right>$rLokasi[syarat_sex]</td>			  
			  <td><a href='../form/frm_par_jenis_cuti.php?op=edit&amp;KL=$rLokasi[id_jcuti]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"par_jns_cuti\",\"$rLokasi[id_jcuti]\",\"\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>		 
			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_jenis_cuti.php\"'>&nbsp;
		  </td>
		 </tr>
		</table>
	";
}
// PARAMETER SETUP (PENDIDIKAN)
elseif($cat == "par_pendidikan"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>";
	echo "<td valign='top' align='center'><br>
		  <a href=\"../form/frm_add_jenjang.php?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=280&width=500\" class=\"thickbox\">
		  	<span class=\"Cell\">  &nbsp;Jenjang&nbsp;  </span>
		  </a>&nbsp;&nbsp;
		  <a href=\"../form/frm_add_fakultas.php?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=250&width=500\" class=\"thickbox\">
		  	<span class=\"Cell\">  &nbsp;Fakultas&nbsp;  </span>
		  </a>&nbsp;&nbsp;
		  <a href=\"../form/frm_add_jurusan.php?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=250&width=500\" class=\"thickbox\">
		  	<span class=\"Cell\">  &nbsp;Jurusan&nbsp;  </span>
		  </a>
		  </td>";	 
	echo "</tr></table>";

	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		 ";
	$result	= mssql_query("SELECT jur.id AS jurid, jen.nama AS jennama, fak.nama AS faknama, jur.nama AS jurnama
						   FROM jenjang jen
						   INNER JOIN fakultas fak ON jen.id=fak.jenjang_id
						   INNER JOIN jurusan jur ON fak.id=jur.fakultas_id",$conn);
	
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY jur.id) AS No, jen.nama AS jennama, fak.nama AS faknama, jur.nama AS jurnama
						   FROM jenjang jen
						   INNER JOIN fakultas fak ON jen.id=fak.jenjang_id
						   INNER JOIN jurusan jur ON fak.id=jur.fakultas_id) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	//echo $sql;
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo"</td>
		 </tr>
		 <tr>
		  <td>
		   <div>
		   <form method=get action=show.php?show=par_lokasi&amp;level=par_lokasi_cari>
		   Masukkan Jenjang/Fakultas/Jurusan: <input type='text' name='keyword' >
		   <input type='hidden' name='show' value='par_pendidikan'>
		   <input type='hidden' name='level' value='par_pendidikan_cari'>
		   <input type='submit' value='Cari!' class=button>
		   </form>
		   </div>
		  </td>
		  <td align=right>
		  
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td width=7%>Jenjang</td>
			  <td width=15%>Fakultas</td>
			  <td>Jurusan</td>
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td align=center>$rLokasi[jennama]</td>
			  <td>$rLokasi[faknama]</td>
			  <td>$rLokasi[jurnama]</td>
			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=right>
		  
		  </td>
		 </tr>
		</table>
	";

}
// PARAMETER SETUP (BANK TRANSFER MEDICAL)
elseif($cat == "par_bank"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		 ";
	if($level == "par_bank_cari")	 
	{
		$result	= mssql_query("SELECT * FROM MstBank WHERE (NamaBank LIKE '%$keyword%')",$conn);
	}
	else{
		$result	= mssql_query("SELECT * FROM MstBank ",$conn);
	}
	
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	if($level == "par_bank_cari")
	{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY IdBank) AS No, * FROM MstBank WHERE (NamaBank LIKE '%$keyword%')) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	else{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY IdBank) AS No, * FROM MstBank) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo"</td>
		 </tr>
		 <tr>
		  <td>
		   <div>
		   <form method=get action=show.php>
		   Masukkan Nama Bank: <input type='text' name='keyword' >
		   <input type='hidden' name='show' value='par_bank'>
		   <input type='hidden' name='level' value='par_bank_cari'>
		   <input type='submit' value='Cari!' class=button>
		   </form>
		   </div>
		  </td>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_bank.php\"'>&nbsp;
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td width=25%>Nama Bank</td>
			  <td width=35%>Cabang</td>
			  <td width=1% colspan=2>&nbsp;</td>		  			  
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td>$rLokasi[NamaBank]</td>
			  <td>$rLokasi[Alamat]</td>
			  <td><a href='../form/frm_par_bank.php?op=edit&amp;KL=$rLokasi[IdBank]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"par_bank\",\"$rLokasi[IdBank]\",\"\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>		 
			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_bank.php\"'>&nbsp;
		  </td>
		 </tr>
		</table>
	";
}
// PARAMETER SETUP (JABATAN)
elseif($cat == "par_jabatan"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		 ";
	if($level == "par_jabatan_cari")	 
	{
		$result	= mssql_query("SELECT * FROM MstJabatan WHERE (jabatan LIKE '%$keyword%') OR (nama LIKE '%$keyword%')",$conn);
	}
	else{
		$result	= mssql_query("SELECT * FROM MstJabatan ",$conn);
	}
	
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	if($level == "par_jabatan_cari")
	{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode) AS No, * FROM MstJabatan WHERE (jabatan LIKE '%$keyword%') OR (nama LIKE '%$keyword%')) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	else{
		$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode) AS No, * FROM MstJabatan) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	}
	
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo"</td>
		 </tr>
		 <tr>
		  <td>
		   <div>
		   <form method=get action=show.php>
		   Masukkan Jabatan: <input type='text' name='keyword' >
		   <input type='hidden' name='show' value='par_jabatan'>
		   <input type='hidden' name='level' value='par_jabatan_cari'>
		   <input type='submit' value='Cari!' class=button>
		   </form>
		   </div>
		  </td>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_jabatan.php\"'>&nbsp;
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td width=25%>Jabatan</td>
			 <!-- <td width=35%>Nama Jabatan</td>-->
			  <td>Fungsional</td>
			  <td>Level Jabatan</td>
			  <td width=1% colspan=2>&nbsp;</td>		  			  
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td>$rLokasi[jabatan]</td>
			  <!--<td>$rLokasi[nama]</td>-->";
			  echo"<td>";
			  if($rLokasi[fungsional] == 1){
			  	echo"Ya";
			  }
			  else{
			   echo"Tidak";
			  }
			  echo"</td>";
			  // get level jabatan
			  $sljab = mssql_query("SELECT nama FROM VLevelJabatan WHERE kode='".$rLokasi[level_jbt]."'",$conn);
			  $rljab = mssql_fetch_array($sljab);
			  echo"<td>$rljab[nama]</td>";
			  
			  echo"<td><a href='../form/frm_par_jabatan.php?op=edit&amp;KL=$rLokasi[kode]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"par_jabatan\",\"$rLokasi[kode]\",\"\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>		 
			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2 align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_jabatan.php\"'>&nbsp;
		  </td>
		 </tr>
		</table>
	";
}
// PARAMETER SETUP (ALL)
elseif($cat == "par_setup"){
	echo"
		<table width=93% class='table_indent2'>
		 <tr>
		  <td colspan=2>&nbsp;&nbsp;<b>PARAMETER SETUP</b></td>
		 </tr>
		 <tr>
		  <td colspan=2>
		 ";
		$result	= mssql_query("WITH LIMIT AS (SELECT ROW_NUMBER() OVER (ORDER BY GroupCode) AS No, GroupCode FROM MstData GROUP BY GroupCode) SELECT * FROM LIMIT  ",$conn);
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY GroupCode) AS No, GroupCode FROM MstData GROUP BY GroupCode) SELECT * FROM limit WHERE GroupCode NOT IN ('database','bhs') AND No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo"</td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table style='position:relative; left: 80px;' width='91%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td width=25%>Group Code</td>
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td><a href='$PHPSELF?show=list_par_setup&amp;group=$rLokasi[GroupCode]'>".strtoupper($rLokasi[GroupCode])."</a></td>
			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		</table>
	";
}
// PARAMETER SETUP (ALL) LIST PAR SETUP
elseif($cat == "list_par_setup"){
$group = $HTTP_GET_VARS['group'];
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		 ";
	$result	= mssql_query("WITH LIMIT AS (SELECT ROW_NUMBER() OVER (ORDER BY GroupCode) AS No, * FROM MstData WHERE GroupCode='$group') SELECT * FROM LIMIT  ",$conn);
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY GroupCode) AS No, * FROM MstData WHERE GroupCode='$group') SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	
	//Paging1($pager,$page,$next,$limit,$keyword,$show);
	Paging2($pager,$page,$next,$limit,$keyword,$show,$group);
	echo"</td>
		 </tr>
		 <tr>
		  <td align=right>
		  <input type=button value='Kembali' class='button'  onclick='Javascript:location.href=\"show.php?show=par_setup\"'>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_par_setup.php?gc=$group\"'>
		   &nbsp;&nbsp;&nbsp;&nbsp;</td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td width=2%>Code</td>
			  <td width=25%>Remarks</td>
			  <td width=25%>ID Code</td>
			  <td colspan=2 width=1%>&nbsp;</td>
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>
			  <td>".strtoupper($rLokasi[Code])."</td>
			  <td>".strtoupper($rLokasi[Remarks])."</td>
  			  <td>".strtoupper($rLokasi[IDCode])."</td>	
			  <td><a href='../form/frm_par_setup.php?op=edit&amp;gc=$rLokasi[GroupCode]&amp;code=$rLokasi[Code]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"par_setup\",\"$rLokasi[GroupCode]\",\"$rLokasi[Code]\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		</table>
	";
}
// BOOK LOG DOWNLOAD
elseif($cat == "log_book_cvonline"){
?>
<script type="text/javascript">
	function HapusL(ID)
	{
		var ok = confirm("Apakah Anda yakin menghapus data tersebut ?");
		if(ok == true)
		{
			window.location.href="<?=$PHP_SELF?>?delete=yes&show=log_book_cvonline&idp="+ID+"";
		}
		else
		{
		}
	}
</script>
<?
	if($_GET['delete'] == "yes"){
		$q = mssql_query("DELETE FROM s_log_cvonline WHERE log_id='".$_GET['idp']."'",$conn);
	}
	
	// filter
	$bulan		= $HTTP_GET_VARS['b2'];
	$tahun		= $HTTP_GET_VARS['t2'];
	$project	= $HTTP_GET_VARS['project_name'];
	$division	= $HTTP_GET_VARS['division'];
	$branch		= $HTTP_GET_VARS['branch'];
	
	if(empty($bulan)){
		$filter = " WHERE periode LIKE '%$bulan%'";
	}
	else{
		$filter = " WHERE periode LIKE '%$bulan%'";
	}
	
	if(empty($tahun)){
		$filter .= "";
	}
	else{
		$filter .= " AND periode LIKE '%$tahun%'";
	}
	
	if(empty($project)){
		$filter .= "";
	}
	else{
		$filter .= " AND project_name LIKE '%$project%'";	
	}
	
	if(empty($division)){
		$filter .= "";
	}
	else{
		$filter .= " AND division LIKE '%$division%'";	
	}
	
	if(empty($branch)){
		$filter .= "";
	}
	else{
		$filter .= " AND branch LIKE '%$branch%'";	
	}	
		 
	$result	= mssql_query("SELECT * FROM S_Log_CVOnline ".$filter."",$conn);
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	echo"
	<table>
	 <tr>
	  <td></td>
	 </tr>
	</table>
	";
	$sql = mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY date_created DESC) AS No, CONVERT(CHAR(12), date_created, 103) tanggal, * FROM S_Log_CVOnline ".$filter.") SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit)." ORDER BY date_created DESC");	
	Paging1($pager,$page,$next,$limit,$keyword,$show);
	echo'<table border=0><tr><td colspan=2 align=\'right\'>
	<tr><td>
	<form action="'.$PHP_SELF.'" method="get">
	<table align=\'center\' border=0 width="100%">
	 <tr>
	  <td colspan=6>Filter berdasarkan:</td>
	 </tr>
	 <tr>
	  <td width=180>Bulan - Tahun:<br>
	  <select name="b2">
		   <option value="">--bulan--</option>
		   <option value="Jan">Januari</option>
		   <option value="Feb">Februari</option>
		   <option value="Mar">Maret</option>
		   <option value="Apr">April</option>
		   <option value="Mei">Mei</option>
		   <option value="Jun">Juni</option>
		   <option value="Jul">Juli</option>
		   <option value="Ags">Agustus</option>
		   <option value="Sep">September</option>
		   <option value="Okt">Oktober</option>
		   <option value="Nov">November</option>
		   <option value="Des">Desember</option>
		  </select> &nbsp;<select name="t2">
		   <option value="">--tahun--</option>';
		   		$ta = date("Y");
		   		for($i=$ta;$i<=($ta+100);$i++){
					echo"<option value='$i'>$i</option>";
				}
		  echo'</select>
		 	 </td>
			 <td width=100>Nama Proyek:<br><input type="text" name="project_name"></td>
			 <td width=100>Unit Kerja:<br> <input type="text" name="division"></td>
			 <!--<td width=100>Cabang:<br><input type="text" name="branch"></td>-->			 
			 <td align=left width=100><br>
			 <input type="hidden" name="show" value="log_book_cvonline">
			 <input type="submit" value="Cari" class="button"></td>
	 		</tr>
		   </table>
		  </td>
		 </tr>';		 
	echo"<tr>
		  <td><br>
		  <fieldset><legend>History</legend>
		   <table width=100%>
		    <tr class='headlist'>
			 <td>No</td>
			 <td>Nama Proyek</td>
			 <td>Periode</td>
			 <td>Tujuan</td>
			 <td>Manager Proyek</td>
			 <td>Divisi</td>
			 <!--<td>Cabang</td>-->
			 <td>Dibuat</td>
			 <td>User Login</td>
			 <td>Jumlah</td>
			 <td>Daftar CV Karyawan<br>(NIK/Nama)</td>
			 <td>&nbsp;</td>
			</tr>";
		while($row = mssql_fetch_array($sql)){
			echo"
			 <tr class='contentlist'>
			  <td>$row[No]</td>
			  <td>$row[project_name]</td>
			  <td>$row[periode]</td>
			  <td>$row[purpose]</td>
			  <td>$row[project_manager]</td>
			  <td>$row[division]</td>
			  <!--<td>$row[branch]</td>-->
			  <td>$row[date_created]</td>
			  <td>$row[userlogin]</td>
			  ";
	 	    $sql_r = mssql_query("SELECT * FROM S_Log_Detail_CVOnline A, Karyawan B WHERE A.NIK=B.NIK AND rand_num='$row[rand_num]' ORDER BY date_created",$conn);
			$con_r = mssql_num_rows($sql_r);
			echo"<td align=center>$con_r</td>
			  <td valign=top>
			   <table cellpadding=0 cellspacing=0>";
			   while($row_r = mssql_fetch_array($sql_r)){
			   echo" 
			  	<tr>
				 <td>&nbsp; <i>$row_r[NIK]</i> $row_r[Nama]</td>
				</tr>";
			   }
			 echo"</table>
			  </td>
			  <td>";
		if($rcvoon[hapus] == 1 ){
		echo"<a href='#' onclick=\"Javascript:HapusL('".$row[log_id]."');\"><img src='../images/b_delete.png' border='0'></a>";
		}
			 echo"</td>
			 </tr>
			";
		}
	echo"</table>
		   </fieldset>
		  </td>
		 </tr>
		</table>
	";
}
// TABLE UNIT KERJA
elseif($cat == "tbl_unit_kerja"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		  <table>
		   <tr>
		    <td><b><a href='".$PHP_SELF."?show=tbl_unit_kerja'>Direktorat</a></b> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_koor'>Koordinator</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_cabang'>Cabang/Biro/Divisi</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_bagian'>Bagian</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_seksi'>Seksi</a></td>
		   </tr>
		  </table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		 ";
	$result	= mssql_query("WITH LIMIT AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, kode_so, uraian, levelso, status, kode_lokasi, areacode FROM VLevelDirektorat) SELECT * FROM LIMIT  ",$conn);
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, * FROM VLevelDirektorat) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	
	Paging2($pager,$page,$next,$limit,$keyword,$show,$group);
	echo"</td>
		 </tr>
		 <tr>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_tbl_uk.php?level=1\"'>
		   &nbsp;&nbsp;&nbsp;&nbsp;</td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td width=25%>Nama</td>
			  <td>Status</td>
			  <td>Kode Lokasi</td>
			  <td>AreaCode</td>
			  <td colspan=2 width=1%>&nbsp;</td>
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>";
//			  <td>".strtoupper($rLokasi[kode_so])."</td>
			echo"  <td>".strtoupper($rLokasi[uraian])."</td>
			  <td>";
			  if($rLokasi[status] == 1){
			  	echo"Aktif";
			  }
			  else{
			  	echo"Non Aktif";
			  }
			echo"</td>	
			  <td>";	
			$sKL = mssql_query("SELECT * FROM MstLokasi WHERE kode_lokasi='".$rLokasi[kode_lokasi]."'",$conn);  
			$rKL = mssql_fetch_array($sKL);
			echo"$rKL[distrik] - $rKL[propinsi]";
			echo"</td><td>".strtoupper($rLokasi[AreaCode])."</td>	
			  <td><a href='../form/frm_tbl_uk.php?op=edit&amp;kodeso=$rLokasi[kode_so]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"tbl_unit_kerja\",\"$rLokasi[kode_so]\",\"$rLokasi[Code]\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		</table>
	";
}
/// UK KOORDINATOR
elseif($cat == "tbl_koor"){
	echo"
		<table width=100%% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		  <table>
		   <tr>
		    <td><a href='".$PHP_SELF."?show=tbl_unit_kerja'>Direktorat</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_koor'><b>Koordinator</b></a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_cabang'>Cabang/Biro/Divisi</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_bagian'>Bagian</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_seksi'>Seksi</a></td>
		   </tr>
		  </table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		 ";
	$result	= mssql_query("WITH LIMIT AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, kode_so, uraian, levelso, status, kode_lokasi, areacode FROM VLevelKoordinator) SELECT * FROM LIMIT  ",$conn);
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, * FROM VLevelKoordinator) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	
	Paging2($pager,$page,$next,$limit,$keyword,$show,$group);
	echo"</td>
		 </tr>
		 <tr>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_tbl_uk.php?level=2\"'>
		   &nbsp;&nbsp;&nbsp;&nbsp;</td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td width=2%>No.</td>
			  <td width=25%>Direktorat</td>
			  <td width=25%>Nama Koor. Teknis</td>
			  <td>Status</td>
			  <td>Kode Lokasi</td>
			  <td>AreaCode</td>
			  <td colspan=2 width=1%>&nbsp;</td>
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>";
			//*/
			$level1	= substr($rLokasi[kode_so],0,2); // direktorat
			$level2 = substr($rLokasi[kode_so],2,2); // koordinator
			$level3 = substr($rLokasi[kode_so],4,3); // cabang biro 
			$level4 = substr($rLokasi[kode_so],7,3); // bagian
			$level5 = substr($rLokasi[kode_so],10,2); //seksi
			
			// get direktorat
			$sql2 = mssql_query("select * from vleveldirektorat where substring(kode_so,1,2)='".$level1."' order by kode_so",$conn);
			if(mssql_num_rows($sql2) > 0){
			$row2 = mssql_fetch_array($sql2);
			echo"
			<td>
			$row2[uraian]
			</td>";
			}
			else{
				echo"<td></td>";
			}
			echo"  
			  <td>".strtoupper($rLokasi[uraian])."</td>
			  <td>";
			  if($rLokasi[status] == 1){
			  	echo"Aktif";
			  }
			  else{
			  	echo"Non Aktif";
			  }
			echo"</td>	
			  <td>";	
			$sKL = mssql_query("SELECT * FROM MstLokasi WHERE kode_lokasi='".$rLokasi[kode_lokasi]."'",$conn);  
			$rKL = mssql_fetch_array($sKL);
			echo"$rKL[distrik] - $rKL[propinsi]";
			echo"</td><td>".strtoupper($rLokasi[AreaCode])."</td>	
			  <td><a href='../form/frm_tbl_uk.php?op=edit&amp;kodeso=$rLokasi[kode_so]&amp;level=1'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"tbl_unit_kerja\",\"$rLokasi[kode_so]\",\"$rLokasi[Code]\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		</table>
	";
}

/// UK CABANG/BIRO
elseif($cat == "tbl_cabang"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		  <table>
		   <tr>
		    <td><a href='".$PHP_SELF."?show=tbl_unit_kerja'>Direktorat</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_koor'>Koordinator</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_cabang'><b>Cabang/Biro/Divisi</b></a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_bagian'>Bagian</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_seksi'>Seksi</a></td>
		   </tr>
		  </table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		 ";
	$result	= mssql_query("WITH LIMIT AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, kode_so, uraian, levelso, status, kode_lokasi, areacode FROM VLevelCabang) SELECT * FROM LIMIT  ",$conn);
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, * FROM VLevelCabang) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	
	Paging2($pager,$page,$next,$limit,$keyword,$show,$group);
	echo"</td>
		 </tr>
		 <tr>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_tbl_uk.php?level=3\"'>
		   &nbsp;&nbsp;&nbsp;&nbsp;</td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table width='100%'>
			 <tr class=headlist>
			  <td >No.</td>
			  <td >Direktorat</td>
			  <td >Koor. Teknis</td>
			  <td >Nama Cabang/Biro/Divisi</td>
			  <td>Status</td>
			  <td>Kode Lokasi</td>
			  <td>AreaCode</td>
			  <td colspan=2 width=1%>&nbsp;</td>
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>";
			//*/
			$level1	= substr($rLokasi[kode_so],0,2); // direktorat
			$level2 = substr($rLokasi[kode_so],2,2); // koordinator
			$level3 = substr($rLokasi[kode_so],4,3); // cabang biro 
			$level4 = substr($rLokasi[kode_so],7,3); // bagian
			$level5 = substr($rLokasi[kode_so],10,2); //seksi
			
			// get direktorat
			$sql2 = mssql_query("select * from vleveldirektorat where substring(kode_so,1,2)='".$level1."' order by kode_so",$conn);
			if(mssql_num_rows($sql2) > 0){
			$row2 = mssql_fetch_array($sql2);
			echo"
			<td>
			$row2[uraian]
			</td>";
			}
			else{
				echo"<td></td>";
			}
			
			// get koordinator teknis
			$sql3 = mssql_query("select * from vlevelkoordinator where substring(kode_so,1,4)='".$level1.$level2."' order by kode_so",$conn);
			if(mssql_num_rows($sql3) > 0){
			$row3 = mssql_fetch_array($sql3);
			echo"<td>$row3[uraian]</td>";
			}
			else{
				echo"<td></td>";
			}

			echo"
			  <td>".strtoupper($rLokasi[uraian])."</td>
			  <td>";
			  if($rLokasi[status] == 1){
			  	echo"Aktif";
			  }
			  else{
			  	echo"Non Aktif";
			  }
			echo"</td>	
			  <td>";	
			$sKL = mssql_query("SELECT * FROM MstLokasi WHERE kode_lokasi='".$rLokasi[kode_lokasi]."'",$conn);  
			$rKL = mssql_fetch_array($sKL);
			echo"$rKL[distrik] - $rKL[propinsi]";
			echo"</td><td>".strtoupper($rLokasi[AreaCode])."</td>	
			  <td><a href='../form/frm_tbl_uk.php?op=edit&amp;kodeso=$rLokasi[kode_so]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"tbl_unit_kerja\",\"$rLokasi[kode_so]\",\"$rLokasi[Code]\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		</table>
	";
}

/// UK BAGIAN
elseif($cat == "tbl_bagian"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		  <table>
		   <tr>
		    <td><a href='".$PHP_SELF."?show=tbl_unit_kerja'>Direktorat</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_koor'>Koordinator</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_cabang'>Cabang/Biro/Divisi</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_bagian'><b>Bagian</b></a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_seksi'>Seksi</a></td>
		   </tr>
		  </table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		 ";
	$result	= mssql_query("WITH LIMIT AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, kode_so, uraian, levelso, status, kode_lokasi, areacode FROM VLevelBagian) SELECT * FROM LIMIT  ",$conn);
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, * FROM VLevelBagian) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	
	Paging2($pager,$page,$next,$limit,$keyword,$show,$group);
	echo"</td>
		 </tr>
		 <tr>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_tbl_uk.php?level=4\"'>
		   &nbsp;&nbsp;&nbsp;&nbsp;</td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table style='position:relative;' width='100%'>
			 <tr class=headlist>
			  <td>No.</td>
			  <td>Direktorat</td>
			  <td>Koor. Teknis</td>
			  <td>Cabang/Divisi/Biro</td>
			  <td>Nama Bagian</td>
			  <td>Status</td>
			  <td>Kode Lokasi</td>
			  <td>AreaCode</td>
			  <td colspan=2 width=1%>&nbsp;</td>
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>";
			//*/
			$level1	= substr($rLokasi[kode_so],0,2); // direktorat
			$level2 = substr($rLokasi[kode_so],2,2); // koordinator
			$level3 = substr($rLokasi[kode_so],4,3); // cabang biro 
			$level4 = substr($rLokasi[kode_so],7,3); // bagian
			$level5 = substr($rLokasi[kode_so],10,2); //seksi
			
			// get direktorat
			$sql2 = mssql_query("select * from vleveldirektorat where substring(kode_so,1,2)='".$level1."' order by kode_so",$conn);
			if(mssql_num_rows($sql2) > 0){
			$row2 = mssql_fetch_array($sql2);
			echo"
			<td>
			$row2[uraian]
			</td>";
			}
			else{
				echo"<td></td>";
			}
			
			// get koordinator teknis
			$sql3 = mssql_query("select * from vlevelkoordinator where substring(kode_so,1,4)='".$level1.$level2."' order by kode_so",$conn);
			if(mssql_num_rows($sql3) > 0){
			$row3 = mssql_fetch_array($sql3);
			echo"<td>$row3[uraian]</td>";
			}
			else{
				echo"<td></td>";
			}

			// get cabang/biro
			$sql4 = mssql_query("select * from vlevelcabang where substring(kode_so,1,7)='".$level1.$level2.$level3."' order by kode_so",$conn);
			if(mssql_num_rows($sql4) > 0){
			$row4 = mssql_fetch_array($sql4);
			echo"<td>$row4[uraian]</td>";
			}
			else{
			echo"<td></td>";
			}
			
			echo"<td>".strtoupper($rLokasi[uraian])."</td>
			  <td>";
			  if($rLokasi[status] == 1){
			  	echo"Aktif";
			  }
			  else{
			  	echo"Non Aktif";
			  }
			echo"</td>	
			  <td>";	
			$sKL = mssql_query("SELECT * FROM MstLokasi WHERE kode_lokasi='".$rLokasi[kode_lokasi]."'",$conn);  
			$rKL = mssql_fetch_array($sKL);
			echo"$rKL[distrik] - $rKL[propinsi]";
			echo"</td><td>".strtoupper($rLokasi[AreaCode])."</td>	
			  <td><a href='../form/frm_tbl_uk.php?op=edit&amp;kodeso=$rLokasi[kode_so]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"tbl_unit_kerja\",\"$rLokasi[kode_so]\",\"$rLokasi[Code]\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		</table>
	";
}
/// UK SEKSI
elseif($cat == "tbl_seksi"){
	echo"
		<table width=100% class='table_indent2'>
		 <tr>
		  <td colspan=2>
		  <table>
		   <tr>
		    <td><a href='".$PHP_SELF."?show=tbl_unit_kerja'>Direktorat</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_koor'>Koordinator</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_cabang'>Cabang/Biro/Divisi</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_bagian'>Bagian</a> |</td>
			<td><a href='".$PHP_SELF."?show=tbl_seksi'><b>Seksi</b></a></td>
		   </tr>
		  </table>
		  </td>
		 </tr>
		 <tr>
		  <td colspan=2>
		 ";
	$result	= mssql_query("WITH LIMIT AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, kode_so, uraian, levelso, status, kode_lokasi, areacode FROM VLevelSeksi) SELECT * FROM LIMIT  ",$conn);
	////
	$total	= mssql_num_rows($result);
	$limit	= 15;
	$pager  = Pager::getPagerData($total, $limit, $page);
	$offset = $pager->offset;
	$limit  = $pager->limit;
	$page   = $pager->page;
	
	///
	$sql	= "WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY kode_so) AS No, * FROM VLevelSeksi) SELECT * FROM limit WHERE No BETWEEN ".$offset." AND ".($offset+$limit).""; 
	
	Paging2($pager,$page,$next,$limit,$keyword,$show,$group);
	echo"</td>
		 </tr>
		 <tr>
		  <td align=right>
		  <input type=button value='Tambah' class='button' onclick='Javascript:location.href=\"../form/frm_tbl_uk.php?level=5\"'>
		   &nbsp;&nbsp;&nbsp;&nbsp;</td>
		 </tr>
		 <tr>
		  <td colspan=2 align=left>
			<table style='position:relative;' width='100%'>
			 <tr class=headlist>
			  <td>No.</td>
			  <td>Direktorat</td>
			  <td>Koor. Teknis</td>
			  <td>Cabang/Biro/Divisi</td>
			  <td>Bagian</td>
			  <td>Nama Seksi</td>
			  <td>Status</td>
			  <td>Kode Lokasi</td>
			  <td>AreaCode</td>
			  <td colspan=2 width=1%>&nbsp;</td>
			 </tr>";
	// cek validasi
	if($total > 0)
	{
		$sLokasi = mssql_query($sql,$conn);
		while($rLokasi = mssql_fetch_array($sLokasi)){
			echo"
			 <tr class=contentlist>
			  <td align=right>$rLokasi[No]</td>";
			//*/
			$level1	= substr($rLokasi[kode_so],0,2); // direktorat
			$level2 = substr($rLokasi[kode_so],2,2); // koordinator
			$level3 = substr($rLokasi[kode_so],4,3); // cabang biro 
			$level4 = substr($rLokasi[kode_so],7,3); // bagian
			$level5 = substr($rLokasi[kode_so],10,2); //seksi
			
			// get direktorat
			$sql2 = mssql_query("select * from vleveldirektorat where substring(kode_so,1,2)='".$level1."' order by kode_so",$conn);
			if(mssql_num_rows($sql2) > 0){
			$row2 = mssql_fetch_array($sql2);
			echo"
			<td>
			$row2[uraian]
			</td>";
			}
			else{
				echo"<td></td>";
			}
			
			// get koordinator teknis
			$sql3 = mssql_query("select * from vlevelkoordinator where substring(kode_so,1,4)='".$level1.$level2."' order by kode_so",$conn);
			if(mssql_num_rows($sql3) > 0){
			$row3 = mssql_fetch_array($sql3);
			echo"<td>$row3[uraian]</td>";
			}
			else{
				echo"<td></td>";
			}

			// get cabang/biro
			$sql4 = mssql_query("select * from vlevelcabang where substring(kode_so,1,7)='".$level1.$level2.$level3."' order by kode_so",$conn);
			if(mssql_num_rows($sql4) > 0){
			$row4 = mssql_fetch_array($sql4);
			echo"<td>$row4[uraian]</td>";
			}
			else{
			echo"<td></td>";
			}
			// get bagian
			$sql5 = mssql_query("select * from vlevelbagian where substring(kode_so,1,10)='".$level1.$level2.$level3.$level4."' order by kode_so",$conn);
			if(mssql_num_rows($sql5) > 0){
			$row5 = mssql_fetch_array($sql5);
				echo"<td> $row5[uraian] </td>";
			}
			else{
				echo"<td></td>";
			}
			echo"
			  <td>".strtoupper($rLokasi[uraian])."</td>
			  <td>";
			  if($rLokasi[status] == 1){
			  	echo"Aktif";
			  }
			  else{
			  	echo"Non Aktif";
			  }
			echo"</td>	
			  <td>";	
			$sKL = mssql_query("SELECT * FROM MstLokasi WHERE kode_lokasi='".$rLokasi[kode_lokasi]."'",$conn);  
			$rKL = mssql_fetch_array($sKL);
			echo"$rKL[distrik] - $rKL[propinsi]";
			echo"</td><td>".strtoupper($rLokasi[AreaCode])."</td>	
			  <td><a href='../form/frm_tbl_uk.php?op=edit&amp;kodeso=$rLokasi[kode_so]'><img src='../images/b_edit.png' title='Edit' alt='Edit' border=0></a></td>
			  <td><a href='#' Onclick='hapus2(\"tbl_unit_kerja\",\"$rLokasi[kode_so]\",\"$rLokasi[Code]\")'><img src='../images/b_delete.png' title='Delete' alt='Delete' border='0'></td>			 </tr>
			";
		}
	}
	else{
		echo"
		 <tr>
		  <td colspan='6' align=center style='color: red;'>
		   	Maaf, Pencarian tidak ditemukan ...
		  </td>
		 </tr>
		";
	}

echo"		</table>
		  </td>
		 </tr>
		</table>
	";
}

echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>